usability: don't ask questions if no reply is required

There has been a bug report by a corporate user that stated that "spelling mistake of stash followed by a yes prints character 'y' infinite times." This analysis was false. When the spelling of a command contains errors, the git program tries to help the user by providing candidates which are close to the unexisting command. E.g Git prints the following: git: 'stahs' is not a git command. See 'git --help'. Did you mean this? stash and then exits. The problem with this hint is that it is not formally indicated as an hint and the user is in fact encouraged to reply to the question, whereas the Git command is already finished. The user was unlucky enough that it was the command he was looking for, and replied "yes" on the command line, effectively launching the `yes` program. The initial error is that the Git programs, when launched in command-line mode (without interaction) must not ask questions, because these questions would normally require a user input as a reply that they won't handle indeed. That's a source of confusion on UX level. To improve the general usability of the Git suite, the following rule was applied: if the sentence * appears in a non-interactive session * is printed last before exit * is a question addressing the user ("you") the sentence is turned into affirmative and proposes the option. The basic rewording of the question sentences has been extended to other spots found in the source. Requested at https://github.com/git/git-scm.com/issues/999 by rpai1 Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jean-Noel Avila committed May 11, 2017 at 14:06 UTC 6c486862636be1fe2d5785451c52f5379b0bad24
3 files changed +7 -7
builtin/am.c
+3 -2
@@ -1313,7 +1313,7 @@ static int parse_mail(struct am_state *state, const char *mail)
1313 }
1314
1315 if (is_empty_file(am_path(state, "patch"))) {
1316 - printf_ln(_("Patch is empty. Was it split wrong?"));
1316 + printf_ln(_("Patch is empty."));
1317 die_user_resolve(state);
1318 }
1319
@@ -1941,7 +1941,8 @@ static void am_resolve(struct am_state *state)
1941
1942 if (unmerged_cache()) {
1943 printf_ln(_("You still have unmerged paths in your index.\n"
1944 - "Did you forget to use 'git add'?"));
1944 + "You should 'git add' each file with resolved conflicts to mark them as such.\n"
1945 + "You might run `git rm` on a file to accept \"deleted by them\" for it."));
1946 die_user_resolve(state);
1947 }
1948
builtin/checkout.c
+2 -3
@@ -1259,9 +1259,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
1259 * new_branch && argc > 1 will be caught later.
1260 */
1261 if (opts.new_branch && argc == 1)
1262 - die(_("Cannot update paths and switch to branch '%s' at the same time.\n"
1263 - "Did you intend to checkout '%s' which can not be resolved as commit?"),
1264 - opts.new_branch, argv[0]);
1262 + die(_("'%s' is not a commit and a branch '%s' cannot be created from it"),
1263 + argv[0], opts.new_branch);
1264
1265 if (opts.force_detach)
1266 die(_("git checkout: --detach does not take a path argument '%s'"),
help.c
+2 -2
@@ -411,8 +411,8 @@ const char *help_unknown_cmd(const char *cmd)
411
412 if (SIMILAR_ENOUGH(best_similarity)) {
413 fprintf_ln(stderr,
414 - Q_("\nDid you mean this?",
415 - "\nDid you mean one of these?",
414 + Q_("\nThe most similar command is",
415 + "\nThe most similar commands are",
416 n));
417
418 for (i = 0; i < n; i++)