Merge branch 'nd/parseopt-completion-more'
authorJunio C Hamano <gitster@pobox.com>
Tue, 10 Apr 2018 07:28:22 +0000 (16:28 +0900)
committerJunio C Hamano <gitster@pobox.com>
Tue, 10 Apr 2018 07:28:22 +0000 (16:28 +0900)
The mechanism to use parse-options API to automate the command line
completion continues to get extended and polished.

* nd/parseopt-completion-more:
completion: use __gitcomp_builtin in _git_cherry
completion: use __gitcomp_builtin in _git_ls_tree
completion: delete option-only completion commands
completion: add --option completion for most builtin commands
completion: factor out _git_xxx calling code
completion: mention the oldest version we need to support
git.c: add hidden option --list-parseopt-builtins
git.c: move cmd_struct declaration up

1  2 
contrib/completion/git-completion.bash
git.c
index b09c8a23626b431a0cb97f6f7f930cccce25bf07,b2b79e0bd41365a2f089889ea8d6ac07b9d78491..a7570739454ac793430b7f0edb8ba229f3ff50d8
@@@ -29,6 -29,8 +29,8 @@@
  # tell the completion to use commit completion.  This also works with aliases
  # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
  #
+ # Compatible with bash 3.2.57.
+ #
  # You can set the following environment variables to influence the behavior of
  # the completion routines:
  #
@@@ -476,7 -478,7 +478,7 @@@ __git_refs (
                        track=""
                        ;;
                *)
 -                      for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do
 +                      for i in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD REBASE_HEAD; do
                                case "$i" in
                                $match*)
                                        if [ -e "$dir/$i" ]; then
@@@ -631,7 -633,7 +633,7 @@@ __git_is_configured_remote (
  
  __git_list_merge_strategies ()
  {
 -      git merge -s help 2>&1 |
 +      LANG=C LC_ALL=C git merge -s help 2>&1 |
        sed -n -e '/[Aa]vailable strategies are: /,/^$/{
                s/\.$//
                s/.*://
@@@ -1109,7 -1111,7 +1111,7 @@@ __git_count_arguments (
  }
  
  __git_whitespacelist="nowarn warn error error-all fix"
 -__git_am_inprogress_options="--skip --continue --resolved --abort"
 +__git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
  
  _git_am ()
  {
@@@ -1284,6 -1286,12 +1286,12 @@@ _git_checkout (
  
  _git_cherry ()
  {
+       case "$cur" in
+       --*)
+               __gitcomp_builtin cherry
+               return
+       esac
        __git_complete_refs
  }
  
@@@ -1503,16 -1511,6 +1511,6 @@@ _git_fsck (
        esac
  }
  
- _git_gc ()
- {
-       case "$cur" in
-       --*)
-               __gitcomp_builtin gc
-               return
-               ;;
-       esac
- }
  _git_gitk ()
  {
        _gitk
@@@ -1637,6 -1635,13 +1635,13 @@@ _git_ls_remote (
  
  _git_ls_tree ()
  {
+       case "$cur" in
+       --*)
+               __gitcomp_builtin ls-tree
+               return
+               ;;
+       esac
        __git_complete_file
  }
  
@@@ -1812,11 -1817,6 +1817,6 @@@ _git_mv (
        fi
  }
  
- _git_name_rev ()
- {
-       __gitcomp_builtin name-rev
- }
  _git_notes ()
  {
        local subcommands='add append copy edit get-ref list merge prune remove show'
@@@ -1933,11 -1933,11 +1933,11 @@@ _git_rebase (
  {
        __git_find_repo_path
        if [ -f "$__git_repo_path"/rebase-merge/interactive ]; then
 -              __gitcomp "--continue --skip --abort --quit --edit-todo"
 +              __gitcomp "--continue --skip --abort --quit --edit-todo --show-current-patch"
                return
        elif [ -d "$__git_repo_path"/rebase-apply ] || \
             [ -d "$__git_repo_path"/rebase-merge ]; then
 -              __gitcomp "--continue --skip --abort --quit"
 +              __gitcomp "--continue --skip --abort --quit --show-current-patch"
                return
        fi
        __git_complete_strategy && return
@@@ -2023,7 -2023,7 +2023,7 @@@ _git_send_email (
                        --compose --confirm= --dry-run --envelope-sender
                        --from --identity
                        --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
 -                      --no-suppress-from --no-thread --quiet
 +                      --no-suppress-from --no-thread --quiet --reply-to
                        --signed-off-by-cc --smtp-pass --smtp-server
                        --smtp-server-port --smtp-encryption= --smtp-user
                        --subject --suppress-cc= --suppress-from --thread --to
@@@ -2971,7 -2971,7 +2971,7 @@@ _git_tag (
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
 -              -d|-v)
 +              -d|--delete|-v|--verify)
                        __gitcomp_direct "$(__git_tags "" "$cur" " ")"
                        return
                        ;;
@@@ -3009,7 -3009,7 +3009,7 @@@ _git_whatchanged (
  
  _git_worktree ()
  {
 -      local subcommands="add list lock prune unlock"
 +      local subcommands="add list lock move prune remove unlock"
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
                __gitcomp "$subcommands"
                prune,--*)
                        __gitcomp_builtin worktree_prune
                        ;;
 +              remove,--*)
 +                      __gitcomp "--force"
 +                      ;;
                *)
                        ;;
                esac
        fi
  }
  
+ __git_complete_common () {
+       local command="$1"
+       case "$cur" in
+       --*)
+               __gitcomp_builtin "$command"
+               ;;
+       esac
+ }
+ __git_cmds_with_parseopt_helper=
+ __git_support_parseopt_helper () {
+       test -n "$__git_cmds_with_parseopt_helper" ||
+               __git_cmds_with_parseopt_helper="$(__git --list-parseopt-builtins)"
+       case " $__git_cmds_with_parseopt_helper " in
+       *" $1 "*)
+               return 0
+               ;;
+       *)
+               return 1
+               ;;
+       esac
+ }
+ __git_complete_command () {
+       local command="$1"
+       local completion_func="_git_${command//-/_}"
+       if declare -f $completion_func >/dev/null 2>/dev/null; then
+               $completion_func
+               return 0
+       elif __git_support_parseopt_helper "$command"; then
+               __git_complete_common "$command"
+               return 0
+       else
+               return 1
+       fi
+ }
  __git_main ()
  {
        local i c=1 command __git_dir __git_repo_path
                return
        fi
  
-       local completion_func="_git_${command//-/_}"
-       declare -f $completion_func >/dev/null 2>/dev/null && $completion_func && return
+       __git_complete_command "$command" && return
  
        local expansion=$(__git_aliased_command "$command")
        if [ -n "$expansion" ]; then
                words[1]=$expansion
-               completion_func="_git_${expansion//-/_}"
-               declare -f $completion_func >/dev/null 2>/dev/null && $completion_func
+               __git_complete_command "$expansion"
        fi
  }
  
diff --combined git.c
index ceaa58ef40e536f1290cce3ad1223004063e41a6,42e7a65d843afc0e2347f003d20613e241413149..3a89893712e6b327e714ad81d12d3e4ca354926c
--- 1/git.c
--- 2/git.c
+++ b/git.c
@@@ -4,12 -4,30 +4,30 @@@
  #include "help.h"
  #include "run-command.h"
  
+ #define RUN_SETUP             (1<<0)
+ #define RUN_SETUP_GENTLY      (1<<1)
+ #define USE_PAGER             (1<<2)
+ /*
+  * require working tree to be present -- anything uses this needs
+  * RUN_SETUP for reading from the configuration file.
+  */
+ #define NEED_WORK_TREE                (1<<3)
+ #define SUPPORT_SUPER_PREFIX  (1<<4)
+ #define DELAY_PAGER_CONFIG    (1<<5)
+ #define NO_PARSEOPT           (1<<6) /* parse-options is not used */
+ struct cmd_struct {
+       const char *cmd;
+       int (*fn)(int, const char **, const char *);
+       unsigned int option;
+ };
  const char git_usage_string[] =
 -      "git [--version] [--help] [-C <path>] [-c name=value]\n"
 -      "           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
 -      "           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
 -      "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 -      "           <command> [<args>]";
 +      N_("git [--version] [--help] [-C <path>] [-c <name>=<value>]\n"
 +         "           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n"
 +         "           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]\n"
 +         "           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n"
 +         "           <command> [<args>]");
  
  const char git_more_info_string[] =
        N_("'git help -a' and 'git help -g' list available subcommands and some\n"
@@@ -18,7 -36,7 +36,7 @@@
  
  static int use_pager = -1;
  
- static void list_builtins(void);
+ static void list_builtins(unsigned int exclude_option, char sep);
  
  static void commit_pager_choice(void) {
        switch (use_pager) {
@@@ -92,7 -110,7 +110,7 @@@ static int handle_options(const char **
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--git-dir")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for --git-dir.\n" );
 +                              fprintf(stderr, _("no directory given for --git-dir\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_DIR_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--namespace")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No namespace given for --namespace.\n" );
 +                              fprintf(stderr, _("no namespace given for --namespace\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--work-tree")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for --work-tree.\n" );
 +                              fprintf(stderr, _("no directory given for --work-tree\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "--super-prefix")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No prefix given for --super-prefix.\n" );
 +                              fprintf(stderr, _("no prefix given for --super-prefix\n" ));
                                usage(git_usage_string);
                        }
                        setenv(GIT_SUPER_PREFIX_ENVIRONMENT, (*argv)[1], 1);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "-c")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "-c expects a configuration string\n" );
 +                              fprintf(stderr, _("-c expects a configuration string\n" ));
                                usage(git_usage_string);
                        }
                        git_config_push_parameter((*argv)[1]);
                                *envchanged = 1;
                } else if (!strcmp(cmd, "-C")) {
                        if (*argc < 2) {
 -                              fprintf(stderr, "No directory given for -C.\n" );
 +                              fprintf(stderr, _("no directory given for -C\n" ));
                                usage(git_usage_string);
                        }
                        if ((*argv)[1][0]) {
                                if (chdir((*argv)[1]))
 -                                      die_errno("Cannot change to '%s'", (*argv)[1]);
 +                                      die_errno("cannot change to '%s'", (*argv)[1]);
                                if (envchanged)
                                        *envchanged = 1;
                        }
                        (*argv)++;
                        (*argc)--;
                } else if (!strcmp(cmd, "--list-builtins")) {
-                       list_builtins();
+                       list_builtins(0, '\n');
+                       exit(0);
+               } else if (!strcmp(cmd, "--list-parseopt-builtins")) {
+                       list_builtins(NO_PARSEOPT, ' ');
                        exit(0);
                } else {
 -                      fprintf(stderr, "Unknown option: %s\n", cmd);
 +                      fprintf(stderr, _("unknown option: %s\n"), cmd);
                        usage(git_usage_string);
                }
  
@@@ -247,7 -268,7 +268,7 @@@ static int handle_alias(int *argcp, con
                        if (ret >= 0)   /* normal exit */
                                exit(ret);
  
 -                      die_errno("While expanding alias '%s': '%s'",
 +                      die_errno("while expanding alias '%s': '%s'",
                            alias_command, alias_string + 1);
                }
                count = split_cmdline(alias_string, &new_argv);
                            split_cmdline_strerror(count));
                option_count = handle_options(&new_argv, &count, &envchanged);
                if (envchanged)
 -                      die("alias '%s' changes environment variables\n"
 -                               "You can use '!git' in the alias to do this.",
 +                      die("alias '%s' changes environment variables.\n"
 +                               "You can use '!git' in the alias to do this",
                                 alias_command);
                memmove(new_argv - option_count, new_argv,
                                count * sizeof(char *));
        return ret;
  }
  
- #define RUN_SETUP             (1<<0)
- #define RUN_SETUP_GENTLY      (1<<1)
- #define USE_PAGER             (1<<2)
- /*
-  * require working tree to be present -- anything uses this needs
-  * RUN_SETUP for reading from the configuration file.
-  */
- #define NEED_WORK_TREE                (1<<3)
- #define SUPPORT_SUPER_PREFIX  (1<<4)
- #define DELAY_PAGER_CONFIG    (1<<5)
- struct cmd_struct {
-       const char *cmd;
-       int (*fn)(int, const char **, const char *);
-       int option;
- };
  static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
  {
        int status, help;
  static struct cmd_struct commands[] = {
        { "add", cmd_add, RUN_SETUP | NEED_WORK_TREE },
        { "am", cmd_am, RUN_SETUP | NEED_WORK_TREE },
-       { "annotate", cmd_annotate, RUN_SETUP },
+       { "annotate", cmd_annotate, RUN_SETUP | NO_PARSEOPT },
        { "apply", cmd_apply, RUN_SETUP_GENTLY },
        { "archive", cmd_archive, RUN_SETUP_GENTLY },
        { "bisect--helper", cmd_bisect__helper, RUN_SETUP },
        { "blame", cmd_blame, RUN_SETUP },
        { "branch", cmd_branch, RUN_SETUP | DELAY_PAGER_CONFIG },
-       { "bundle", cmd_bundle, RUN_SETUP_GENTLY },
+       { "bundle", cmd_bundle, RUN_SETUP_GENTLY | NO_PARSEOPT },
        { "cat-file", cmd_cat_file, RUN_SETUP },
        { "check-attr", cmd_check_attr, RUN_SETUP },
        { "check-ignore", cmd_check_ignore, RUN_SETUP | NEED_WORK_TREE },
        { "check-mailmap", cmd_check_mailmap, RUN_SETUP },
-       { "check-ref-format", cmd_check_ref_format },
+       { "check-ref-format", cmd_check_ref_format, NO_PARSEOPT  },
        { "checkout", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },
        { "checkout-index", cmd_checkout_index,
                RUN_SETUP | NEED_WORK_TREE},
        { "clone", cmd_clone },
        { "column", cmd_column, RUN_SETUP_GENTLY },
        { "commit", cmd_commit, RUN_SETUP | NEED_WORK_TREE },
-       { "commit-tree", cmd_commit_tree, RUN_SETUP },
+       { "commit-tree", cmd_commit_tree, RUN_SETUP | NO_PARSEOPT },
 -      { "config", cmd_config, RUN_SETUP_GENTLY },
 +      { "config", cmd_config, RUN_SETUP_GENTLY | DELAY_PAGER_CONFIG },
        { "count-objects", cmd_count_objects, RUN_SETUP },
-       { "credential", cmd_credential, RUN_SETUP_GENTLY },
+       { "credential", cmd_credential, RUN_SETUP_GENTLY | NO_PARSEOPT },
        { "describe", cmd_describe, RUN_SETUP },
-       { "diff", cmd_diff },
-       { "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE },
-       { "diff-index", cmd_diff_index, RUN_SETUP },
-       { "diff-tree", cmd_diff_tree, RUN_SETUP },
+       { "diff", cmd_diff, NO_PARSEOPT },
+       { "diff-files", cmd_diff_files, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
+       { "diff-index", cmd_diff_index, RUN_SETUP | NO_PARSEOPT },
+       { "diff-tree", cmd_diff_tree, RUN_SETUP | NO_PARSEOPT },
        { "difftool", cmd_difftool, RUN_SETUP | NEED_WORK_TREE },
        { "fast-export", cmd_fast_export, RUN_SETUP },
        { "fetch", cmd_fetch, RUN_SETUP },
-       { "fetch-pack", cmd_fetch_pack, RUN_SETUP },
+       { "fetch-pack", cmd_fetch_pack, RUN_SETUP | NO_PARSEOPT },
        { "fmt-merge-msg", cmd_fmt_merge_msg, RUN_SETUP },
        { "for-each-ref", cmd_for_each_ref, RUN_SETUP },
        { "format-patch", cmd_format_patch, RUN_SETUP },
        { "fsck", cmd_fsck, RUN_SETUP },
        { "fsck-objects", cmd_fsck, RUN_SETUP },
        { "gc", cmd_gc, RUN_SETUP },
-       { "get-tar-commit-id", cmd_get_tar_commit_id },
+       { "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
        { "grep", cmd_grep, RUN_SETUP_GENTLY },
        { "hash-object", cmd_hash_object },
        { "help", cmd_help },
-       { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY },
+       { "index-pack", cmd_index_pack, RUN_SETUP_GENTLY | NO_PARSEOPT },
        { "init", cmd_init_db },
        { "init-db", cmd_init_db },
        { "interpret-trailers", cmd_interpret_trailers, RUN_SETUP_GENTLY },
        { "ls-files", cmd_ls_files, RUN_SETUP },
        { "ls-remote", cmd_ls_remote, RUN_SETUP_GENTLY },
        { "ls-tree", cmd_ls_tree, RUN_SETUP },
-       { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY },
-       { "mailsplit", cmd_mailsplit },
+       { "mailinfo", cmd_mailinfo, RUN_SETUP_GENTLY | NO_PARSEOPT },
+       { "mailsplit", cmd_mailsplit, NO_PARSEOPT },
        { "merge", cmd_merge, RUN_SETUP | NEED_WORK_TREE },
        { "merge-base", cmd_merge_base, RUN_SETUP },
        { "merge-file", cmd_merge_file, RUN_SETUP_GENTLY },
-       { "merge-index", cmd_merge_index, RUN_SETUP },
-       { "merge-ours", cmd_merge_ours, RUN_SETUP },
-       { "merge-recursive", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
-       { "merge-recursive-ours", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
-       { "merge-recursive-theirs", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
-       { "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },
-       { "merge-tree", cmd_merge_tree, RUN_SETUP },
-       { "mktag", cmd_mktag, RUN_SETUP },
+       { "merge-index", cmd_merge_index, RUN_SETUP | NO_PARSEOPT },
+       { "merge-ours", cmd_merge_ours, RUN_SETUP | NO_PARSEOPT },
+       { "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 },
+       { "merge-subtree", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE | NO_PARSEOPT },
+       { "merge-tree", cmd_merge_tree, RUN_SETUP | NO_PARSEOPT },
+       { "mktag", cmd_mktag, RUN_SETUP | NO_PARSEOPT },
        { "mktree", cmd_mktree, RUN_SETUP },
        { "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
        { "name-rev", cmd_name_rev, RUN_SETUP },
        { "notes", cmd_notes, RUN_SETUP },
        { "pack-objects", cmd_pack_objects, RUN_SETUP },
-       { "pack-redundant", cmd_pack_redundant, RUN_SETUP },
+       { "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT },
        { "pack-refs", cmd_pack_refs, RUN_SETUP },
-       { "patch-id", cmd_patch_id, RUN_SETUP_GENTLY },
+       { "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
        { "pickaxe", cmd_blame, RUN_SETUP },
        { "prune", cmd_prune, RUN_SETUP },
        { "prune-packed", cmd_prune_packed, RUN_SETUP },
        { "receive-pack", cmd_receive_pack },
        { "reflog", cmd_reflog, RUN_SETUP },
        { "remote", cmd_remote, RUN_SETUP },
-       { "remote-ext", cmd_remote_ext },
-       { "remote-fd", cmd_remote_fd },
+       { "remote-ext", cmd_remote_ext, NO_PARSEOPT },
+       { "remote-fd", cmd_remote_fd, NO_PARSEOPT },
        { "repack", cmd_repack, RUN_SETUP },
        { "replace", cmd_replace, RUN_SETUP },
        { "rerere", cmd_rerere, RUN_SETUP },
        { "reset", cmd_reset, RUN_SETUP },
-       { "rev-list", cmd_rev_list, RUN_SETUP },
-       { "rev-parse", cmd_rev_parse },
+       { "rev-list", cmd_rev_list, RUN_SETUP | NO_PARSEOPT },
+       { "rev-parse", cmd_rev_parse, NO_PARSEOPT },
        { "revert", cmd_revert, RUN_SETUP | NEED_WORK_TREE },
        { "rm", cmd_rm, RUN_SETUP },
        { "send-pack", cmd_send_pack, RUN_SETUP },
        { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
        { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
        { "stripspace", cmd_stripspace },
-       { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},
+       { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX | NO_PARSEOPT },
        { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
        { "tag", cmd_tag, RUN_SETUP | DELAY_PAGER_CONFIG },
-       { "unpack-file", cmd_unpack_file, RUN_SETUP },
-       { "unpack-objects", cmd_unpack_objects, RUN_SETUP },
+       { "unpack-file", cmd_unpack_file, RUN_SETUP | NO_PARSEOPT },
+       { "unpack-objects", cmd_unpack_objects, RUN_SETUP | NO_PARSEOPT },
        { "update-index", cmd_update_index, RUN_SETUP },
        { "update-ref", cmd_update_ref, RUN_SETUP },
        { "update-server-info", cmd_update_server_info, RUN_SETUP },
-       { "upload-archive", cmd_upload_archive },
-       { "upload-archive--writer", cmd_upload_archive_writer },
-       { "var", cmd_var, RUN_SETUP_GENTLY },
+       { "upload-archive", cmd_upload_archive, NO_PARSEOPT },
+       { "upload-archive--writer", cmd_upload_archive_writer, NO_PARSEOPT },
+       { "var", cmd_var, RUN_SETUP_GENTLY | NO_PARSEOPT },
        { "verify-commit", cmd_verify_commit, RUN_SETUP },
        { "verify-pack", cmd_verify_pack },
        { "verify-tag", cmd_verify_tag, RUN_SETUP },
        { "version", cmd_version },
        { "whatchanged", cmd_whatchanged, RUN_SETUP },
-       { "worktree", cmd_worktree, RUN_SETUP },
+       { "worktree", cmd_worktree, RUN_SETUP | NO_PARSEOPT },
        { "write-tree", cmd_write_tree, RUN_SETUP },
  };
  
@@@ -504,11 -508,15 +508,15 @@@ int is_builtin(const char *s
        return !!get_builtin(s);
  }
  
- static void list_builtins(void)
+ static void list_builtins(unsigned int exclude_option, char sep)
  {
        int i;
-       for (i = 0; i < ARRAY_SIZE(commands); i++)
-               printf("%s\n", commands[i].cmd);
+       for (i = 0; i < ARRAY_SIZE(commands); i++) {
+               if (exclude_option &&
+                   (commands[i].option & exclude_option))
+                       continue;
+               printf("%s%c", commands[i].cmd, sep);
+       }
  }
  
  #ifdef STRIP_EXTENSION
@@@ -684,8 -692,8 +692,8 @@@ int cmd_main(int argc, const char **arg
                if (errno != ENOENT)
                        break;
                if (was_alias) {
 -                      fprintf(stderr, "Expansion of alias '%s' failed; "
 -                              "'%s' is not a git command\n",
 +                      fprintf(stderr, _("expansion of alias '%s' failed; "
 +                                        "'%s' is not a git command\n"),
                                cmd, argv[0]);
                        exit(1);
                }
                        break;
        }
  
 -      fprintf(stderr, "Failed to run command '%s': %s\n",
 +      fprintf(stderr, _("failed to run command '%s': %s\n"),
                cmd, strerror(errno));
  
        return 1;