Merge branch 'mb/reword-autocomplete-message' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2017 20:59:04 +0000 (13:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 10 Jul 2017 20:59:04 +0000 (13:59 -0700)
Message update.

* mb/reword-autocomplete-message:
auto-correct: tweak phrasing

1  2 
help.c
diff --combined help.c
index b44c55ec2da515d12c1327f01202621738fa8653,2a8ae9758db3a3dfe2d150089017eab972e5fb59..9d2811efdabb55bd8ddd89e76a6d461801f7eced
--- 1/help.c
--- 2/help.c
+++ b/help.c
@@@ -1,7 -1,6 +1,7 @@@
  #include "cache.h"
  #include "builtin.h"
  #include "exec_cmd.h"
 +#include "run-command.h"
  #include "levenshtein.h"
  #include "help.h"
  #include "common-cmds.h"
@@@ -97,6 -96,33 +97,6 @@@ static void pretty_print_cmdnames(struc
        string_list_clear(&list, 0);
  }
  
 -static int is_executable(const char *name)
 -{
 -      struct stat st;
 -
 -      if (stat(name, &st) || /* stat, not lstat */
 -          !S_ISREG(st.st_mode))
 -              return 0;
 -
 -#if defined(GIT_WINDOWS_NATIVE)
 -{     /* cannot trust the executable bit, peek into the file instead */
 -      char buf[3] = { 0 };
 -      int n;
 -      int fd = open(name, O_RDONLY);
 -      st.st_mode &= ~S_IXUSR;
 -      if (fd >= 0) {
 -              n = read(fd, buf, 2);
 -              if (n == 2)
 -                      /* DOS executables start with "MZ" */
 -                      if (!strcmp(buf, "#!") || !strcmp(buf, "MZ"))
 -                              st.st_mode |= S_IXUSR;
 -              close(fd);
 -      }
 -}
 -#endif
 -      return st.st_mode & S_IXUSR;
 -}
 -
  static void list_commands_in_dir(struct cmdnames *cmds,
                                         const char *path,
                                         const char *prefix)
@@@ -144,7 -170,8 +144,7 @@@ void load_command_list(const char *pref
  
        if (exec_path) {
                list_commands_in_dir(main_cmds, exec_path, prefix);
 -              qsort(main_cmds->names, main_cmds->cnt,
 -                    sizeof(*main_cmds->names), cmdname_compare);
 +              QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare);
                uniq(main_cmds);
        }
  
                }
                free(paths);
  
 -              qsort(other_cmds->names, other_cmds->cnt,
 -                    sizeof(*other_cmds->names), cmdname_compare);
 +              QSORT(other_cmds->names, other_cmds->cnt, cmdname_compare);
                uniq(other_cmds);
        }
        exclude_cmds(other_cmds, main_cmds);
@@@ -210,7 -238,8 +210,7 @@@ void list_common_cmds_help(void
                        longest = strlen(common_cmds[i].name);
        }
  
 -      qsort(common_cmds, ARRAY_SIZE(common_cmds),
 -              sizeof(common_cmds[0]), cmd_group_cmp);
 +      QSORT(common_cmds, ARRAY_SIZE(common_cmds), cmd_group_cmp);
  
        puts(_("These are common Git commands used in various situations:"));
  
@@@ -289,13 -318,14 +289,13 @@@ const char *help_unknown_cmd(const cha
        memset(&other_cmds, 0, sizeof(other_cmds));
        memset(&aliases, 0, sizeof(aliases));
  
 -      git_config(git_unknown_cmd_config, NULL);
 +      read_early_config(git_unknown_cmd_config, NULL);
  
        load_command_list("git-", &main_cmds, &other_cmds);
  
        add_cmd_list(&main_cmds, &aliases);
        add_cmd_list(&main_cmds, &other_cmds);
 -      qsort(main_cmds.names, main_cmds.cnt,
 -            sizeof(*main_cmds.names), cmdname_compare);
 +      QSORT(main_cmds.names, main_cmds.cnt, cmdname_compare);
        uniq(&main_cmds);
  
        /* This abuses cmdname->len for levenshtein distance */
                        levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
        }
  
 -      qsort(main_cmds.names, main_cmds.cnt,
 -            sizeof(*main_cmds.names), levenshtein_compare);
 +      QSORT(main_cmds.names, main_cmds.cnt, levenshtein_compare);
  
        if (!main_cmds.cnt)
                die(_("Uh oh. Your system reports no Git commands at all."));
                clean_cmdnames(&main_cmds);
                fprintf_ln(stderr,
                           _("WARNING: You called a Git command named '%s', "
-                            "which does not exist.\n"
-                            "Continuing under the assumption that you meant '%s'"),
-                       cmd, assumed);
-               if (autocorrect > 0) {
-                       fprintf_ln(stderr, _("in %0.1f seconds automatically..."),
-                               (float)autocorrect/10.0);
+                            "which does not exist."),
+                          cmd);
+               if (autocorrect < 0)
+                       fprintf_ln(stderr,
+                                  _("Continuing under the assumption that "
+                                    "you meant '%s'."),
+                                  assumed);
+               else {
+                       fprintf_ln(stderr,
+                                  _("Continuing in %0.1f seconds, "
+                                    "assuming that you meant '%s'."),
+                                  (float)autocorrect/10.0, assumed);
                        sleep_millisec(autocorrect * 100);
                }
                return assumed;
  
        if (SIMILAR_ENOUGH(best_similarity)) {
                fprintf_ln(stderr,
 -                         Q_("\nDid you mean this?",
 -                            "\nDid you mean one of these?",
 +                         Q_("\nThe most similar command is",
 +                            "\nThe most similar commands are",
                           n));
  
                for (i = 0; i < n; i++)