Skip to content

Commit 8c08819

Browse files
committed
[Outreachy] merge-ours: include parse-options
Teach this command which currently handles its own argv to use parse-options instead because parse-options helps make sure we handle user input like -h in a standardized way across the project. Also deleted the NO_PARSEOPT flag from git.c to coincide with the conversion of the structure in this command since merge-ours now uses parse-options and needed to update git.c accordingly. Signed-off-by: george espinoza <[email protected]>
1 parent 566a143 commit 8c08819

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

builtin/merge-ours.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,20 @@
1111
#include "git-compat-util.h"
1212
#include "builtin.h"
1313
#include "diff.h"
14+
#include "parse-options.h"
1415

15-
static const char builtin_merge_ours_usage[] =
16-
"git merge-ours <base>... -- HEAD <remote>...";
16+
static const char * const merge_ours_usage[] = {
17+
N_("git merge-ours [<base>...] -- <head> <merge-head>..."),
18+
NULL,
19+
};
1720

1821
int cmd_merge_ours(int argc, const char **argv, const char *prefix)
1922
{
20-
if (argc == 2 && !strcmp(argv[1], "-h"))
21-
usage(builtin_merge_ours_usage);
23+
struct option options[] = {
24+
OPT_END()
25+
};
26+
27+
argc = parse_options(argc, argv, prefix, options, merge_ours_usage, 0);
2228

2329
/*
2430
* The contents of the current index becomes the tree we

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ static struct cmd_struct commands[] = {
527527
{ "merge-base", cmd_merge_base, RUN_SETUP },
528528
{ "merge-file", cmd_merge_file, RUN_SETUP_GENTLY },
529529
{ "merge-index", cmd_merge_index, RUN_SETUP | NO_PARSEOPT },
530-
{ "merge-ours", cmd_merge_ours, RUN_SETUP | NO_PARSEOPT },
530+
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
531531
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
532532
{ "merge-recursive-ours", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
533533
{ "merge-recursive-theirs", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },

0 commit comments

Comments
 (0)