Merge branch 'rs/opt-updates'
authorJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:43 +0000 (14:33 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Aug 2018 21:33:43 +0000 (14:33 -0700)
"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

1  2 
builtin/checkout-index.c
builtin/pull.c
builtin/push.c
builtin/remote.c
builtin/send-pack.c
diff --combined builtin/checkout-index.c
index d92db62fbdf15c14ff3d85b767a069b22aa3897d,92e9d0d69f8f63619c7824af6ffc64864d486674..88b86c8d9f5a0ea9c49b42e891082203b80a977f
@@@ -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 <string>")),
-               { 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()
  
        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 53bc5facfdabd05934a351091f2040744b2575ca,6eebb240da21585363ed77af25d6ee68ce8a27a0..681c127a07071c98641972227a28dbe7f77eaf70
@@@ -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))
                        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 ef4c188895beab317a66523b23a9f1c87e634405,b5a941ccc2214d52ad41409bf4b83799bc0f9e1c..d09a42062c36d930b8147d6b0a4bcfedf34a2321
@@@ -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>:<expect"),
 +                0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
                  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),
                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 07bd51f8eb348036e7e1446d513e46e2877ec6a9,4f95d21b5d8484455dc1342bb9800ce57eeafb3d..7876db1c20d317e28e4a84880197c6a690bf9ef6
@@@ -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;
  
                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 724b4848508d67b3693edf458033e7e29a92b3d3,bca6ea22dd15abe4fce1fe865170f276bd56a72f..8e3c7490f70df79497ee064ab13c0164de11fe9e
@@@ -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)
                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"),
                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>:<expect"),
 +                0, CAS_OPT_NAME, &cas, N_("<refname>:<expect>"),
                  N_("require old value of ref to be at this value"),
                  PARSE_OPT_OPTARG, parseopt_push_cas_option },
                OPT_END()