Skip to content

Commit

Permalink
[Outreachy] merge-ours: include parse-options
Browse files Browse the repository at this point in the history
This command currently handles its own argv so by teaching it to
use parse-options instead we can standardize the way commands
handle user input across the project. ex. -h.
NO_PARSEOPT flag was also removed to update git.c with the
conversion of the structure in this command.

Helped by: emily shaffer <[email protected]>
Helped by: johannes schindelin <[email protected]>

Signed-off-by: george espinoza <[email protected]>
  • Loading branch information
Georgecanfly committed Oct 29, 2019
1 parent 566a143 commit 085aeea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions builtin/merge-ours.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
#include "git-compat-util.h"
#include "builtin.h"
#include "diff.h"
#include "parse-options.h"

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

int cmd_merge_ours(int argc, const char **argv, const char *prefix)
{
if (argc == 2 && !strcmp(argv[1], "-h"))
usage(builtin_merge_ours_usage);
struct option options[] = {
OPT_END()
};

argc = parse_options(argc, argv, prefix, options, merge_ours_usage, 0);

/*
* The contents of the current index becomes the tree we
Expand Down
2 changes: 1 addition & 1 deletion git.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static struct cmd_struct commands[] = {
{ "merge-base", cmd_merge_base, RUN_SETUP },
{ "merge-file", cmd_merge_file, RUN_SETUP_GENTLY },
{ "merge-index", cmd_merge_index, RUN_SETUP | NO_PARSEOPT },
{ "merge-ours", cmd_merge_ours, RUN_SETUP | NO_PARSEOPT },
{ "merge-ours", cmd_merge_ours, RUN_SETUP },
{ "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
{ "merge-recursive-ours", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
{ "merge-recursive-theirs", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
Expand Down

0 comments on commit 085aeea

Please sign in to comment.