From: Junio C Hamano Date: Mon, 27 Aug 2018 21:33:43 +0000 (-0700) Subject: Merge branch 'rs/opt-updates' X-Git-Tag: v2.19.0-rc1~16 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/fc0df933c8fa09603a9e9798085ee07ca1a83f65?hp=-c Merge branch 'rs/opt-updates' "git cmd -h" updates. * rs/opt-updates: parseopt: group literal string alternatives in argument help remote: improve argument help for add --mirror checkout-index: improve argument help for --stage --- fc0df933c8fa09603a9e9798085ee07ca1a83f65 diff --combined builtin/checkout-index.c index d92db62fbd,92e9d0d69f..88b86c8d9f --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@@ -172,7 -172,7 +172,7 @@@ int cmd_checkout_index(int argc, const N_("write the content to temporary files")), OPT_STRING(0, "prefix", &state.base_dir, N_("string"), N_("when creating files, prepend ")), - { OPTION_CALLBACK, 0, "stage", NULL, "1-3|all", + { OPTION_CALLBACK, 0, "stage", NULL, "(1|2|3|all)", N_("copy out the files from named stage"), PARSE_OPT_NONEG, option_parse_stage }, OPT_END() @@@ -190,7 -190,6 +190,7 @@@ argc = parse_options(argc, argv, prefix, builtin_checkout_index_options, builtin_checkout_index_usage, 0); + state.istate = &the_index; state.force = force; state.quiet = quiet; state.not_new = not_new; diff --combined builtin/pull.c index 53bc5facfd,6eebb240da..681c127a07 --- a/builtin/pull.c +++ b/builtin/pull.c @@@ -48,11 -48,11 +48,11 @@@ static enum rebase_type parse_config_re return REBASE_FALSE; else if (v > 0) return REBASE_TRUE; - else if (!strcmp(value, "preserve")) + else if (!strcmp(value, "preserve") || !strcmp(value, "p")) return REBASE_PRESERVE; - else if (!strcmp(value, "merges")) + else if (!strcmp(value, "merges") || !strcmp(value, "m")) return REBASE_MERGES; - else if (!strcmp(value, "interactive")) + else if (!strcmp(value, "interactive") || !strcmp(value, "i")) return REBASE_INTERACTIVE; if (fatal) @@@ -135,7 -135,7 +135,7 @@@ static struct option pull_options[] = /* Options passed to git-merge or git-rebase */ OPT_GROUP(N_("Options related to merging")), { OPTION_CALLBACK, 'r', "rebase", &opt_rebase, - "false|true|merges|preserve|interactive", + "(false|true|merges|preserve|interactive)", N_("incorporate changes by rebasing rather than merging"), PARSE_OPT_OPTARG, parse_opt_rebase }, OPT_PASSTHRU('n', NULL, &opt_diffstat, NULL, @@@ -356,7 -356,7 +356,7 @@@ static int git_pull_config(const char * */ static void get_merge_heads(struct oid_array *merge_heads) { - const char *filename = git_path_fetch_head(); + const char *filename = git_path_fetch_head(the_repository); FILE *fp; struct strbuf sb = STRBUF_INIT; struct object_id oid; @@@ -684,7 -684,7 +684,7 @@@ static const char *get_tracking_branch( const char *spec_src; const char *merge_branch; - refspec_item_init(&spec, refspec, REFSPEC_FETCH); + refspec_item_init_or_die(&spec, refspec, REFSPEC_FETCH); spec_src = spec.src; if (!*spec_src || !strcmp(spec_src, "HEAD")) spec_src = "HEAD"; @@@ -765,13 -765,10 +765,13 @@@ static int get_octopus_merge_base(struc { struct commit_list *revs = NULL, *result; - commit_list_insert(lookup_commit_reference(curr_head), &revs); - commit_list_insert(lookup_commit_reference(merge_head), &revs); + commit_list_insert(lookup_commit_reference(the_repository, curr_head), + &revs); + commit_list_insert(lookup_commit_reference(the_repository, merge_head), + &revs); if (!is_null_oid(fork_point)) - commit_list_insert(lookup_commit_reference(fork_point), &revs); + commit_list_insert(lookup_commit_reference(the_repository, fork_point), + &revs); result = get_octopus_merge_bases(revs); free_commit_list(revs); @@@ -867,7 -864,7 +867,7 @@@ int cmd_pull(int argc, const char **arg if (read_cache_unmerged()) die_resolve_conflict("pull"); - if (file_exists(git_path_merge_head())) + if (file_exists(git_path_merge_head(the_repository))) die_conclude_merge(); if (get_oid("HEAD", &orig_head)) @@@ -947,11 -944,9 +947,11 @@@ struct commit_list *list = NULL; struct commit *merge_head, *head; - head = lookup_commit_reference(&orig_head); + head = lookup_commit_reference(the_repository, + &orig_head); commit_list_insert(head, &list); - merge_head = lookup_commit_reference(&merge_heads.oid[0]); + merge_head = lookup_commit_reference(the_repository, + &merge_heads.oid[0]); if (is_descendant_of(merge_head, list)) { /* we can fast-forward this without invoking rebase */ opt_ff = "--ff-only"; diff --combined builtin/push.c index ef4c188895,b5a941ccc2..d09a42062c --- a/builtin/push.c +++ b/builtin/push.c @@@ -558,10 -558,10 +558,10 @@@ int cmd_push(int argc, const char **arg OPT_BIT( 0, "porcelain", &flags, N_("machine-readable output"), TRANSPORT_PUSH_PORCELAIN), OPT_BIT('f', "force", &flags, N_("force updates"), TRANSPORT_PUSH_FORCE), { OPTION_CALLBACK, - 0, CAS_OPT_NAME, &cas, N_("refname>::"), N_("require old value of ref to be at this value"), - PARSE_OPT_OPTARG, parseopt_push_cas_option }, + PARSE_OPT_OPTARG | PARSE_OPT_LITERAL_ARGHELP, parseopt_push_cas_option }, - { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "check|on-demand|no", + { OPTION_CALLBACK, 0, "recurse-submodules", &recurse_submodules, "(check|on-demand|no)", N_("control recursive pushing of submodules"), PARSE_OPT_OPTARG, option_parse_recurse_submodules }, OPT_BOOL_F( 0 , "thin", &thin, N_("use thin pack"), PARSE_OPT_NOCOMPLETE), @@@ -576,7 -576,7 +576,7 @@@ OPT_BIT(0, "follow-tags", &flags, N_("push missing but relevant tags"), TRANSPORT_PUSH_FOLLOW_TAGS), { OPTION_CALLBACK, - 0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"), + 0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"), PARSE_OPT_OPTARG, option_parse_push_signed }, OPT_BIT(0, "atomic", &flags, N_("request atomic transaction on remote side"), TRANSPORT_PUSH_ATOMIC), OPT_STRING_LIST('o', "push-option", &push_options_cmdline, N_("server-specific"), N_("option to transmit")), diff --combined builtin/remote.c index 07bd51f8eb,4f95d21b5d..7876db1c20 --- a/builtin/remote.c +++ b/builtin/remote.c @@@ -8,7 -8,6 +8,7 @@@ #include "run-command.h" #include "refs.h" #include "refspec.h" +#include "object-store.h" #include "argv-array.h" static const char * const builtin_remote_usage[] = { @@@ -168,7 -167,7 +168,7 @@@ static int add(int argc, const char **a OPT_STRING_LIST('t', "track", &track, N_("branch"), N_("branch(es) to track")), OPT_STRING('m', "master", &master, N_("branch"), N_("master branch")), - { OPTION_CALLBACK, 0, "mirror", &mirror, N_("push|fetch"), + { OPTION_CALLBACK, 0, "mirror", &mirror, "(push|fetch)", N_("set up remote as a mirror to push to or fetch from"), PARSE_OPT_OPTARG | PARSE_OPT_COMP_ARG, parse_mirror_opt }, OPT_END() @@@ -566,7 -565,7 +566,7 @@@ static int read_remote_branches(const c strbuf_addf(&buf, "refs/remotes/%s/", rename->old_name); if (starts_with(refname, buf.buf)) { - item = string_list_append(rename->remote_branches, xstrdup(refname)); + item = string_list_append(rename->remote_branches, refname); symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL, &flag); if (symref && (flag & REF_ISSYMREF)) @@@ -612,7 -611,7 +612,7 @@@ static int mv(int argc, const char **ar struct remote *oldremote, *newremote; struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT, buf3 = STRBUF_INIT, old_remote_context = STRBUF_INIT; - struct string_list remote_branches = STRING_LIST_INIT_NODUP; + struct string_list remote_branches = STRING_LIST_INIT_DUP; struct rename_info rename; int i, refspec_updated = 0; @@@ -734,7 -733,6 +734,7 @@@ if (create_symref(buf.buf, buf2.buf, buf3.buf)) die(_("creating '%s' failed"), buf.buf); } + string_list_clear(&remote_branches, 1); return 0; } diff --combined builtin/send-pack.c index 724b484850,bca6ea22dd..8e3c7490f7 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@@ -121,7 -121,7 +121,7 @@@ static int send_pack_config(const char } } } - return 0; + return git_default_config(k, v, cb); } int cmd_send_pack(int argc, const char **argv, const char *prefix) @@@ -166,7 -166,7 +166,7 @@@ OPT_BOOL(0, "mirror", &send_mirror, N_("mirror all refs")), OPT_BOOL('f', "force", &force_update, N_("force updates")), { OPTION_CALLBACK, - 0, "signed", &push_cert, "yes|no|if-asked", N_("GPG sign the push"), + 0, "signed", &push_cert, "(yes|no|if-asked)", N_("GPG sign the push"), PARSE_OPT_OPTARG, option_parse_push_signed }, OPT_STRING_LIST(0, "push-option", &push_options, N_("server-specific"), @@@ -178,7 -178,7 +178,7 @@@ OPT_BOOL(0, "stdin", &from_stdin, N_("read refs from stdin")), OPT_BOOL(0, "helper-status", &helper_status, N_("print status from remote helper")), { OPTION_CALLBACK, - 0, CAS_OPT_NAME, &cas, N_("refname>::"), N_("require old value of ref to be at this value"), PARSE_OPT_OPTARG, parseopt_push_cas_option }, OPT_END()