Skip to content

Commit 6c48686

Browse files
jnavilagitster
authored andcommitted
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 git/git-scm.com#999 by rpai1 Signed-off-by: Jean-Noel Avila <jn.avila@free.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 49800c9 commit 6c48686

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

builtin/am.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,7 @@ static int parse_mail(struct am_state *state, const char *mail)
13131313
}
13141314

13151315
if (is_empty_file(am_path(state, "patch"))) {
1316-
printf_ln(_("Patch is empty. Was it split wrong?"));
1316+
printf_ln(_("Patch is empty."));
13171317
die_user_resolve(state);
13181318
}
13191319

@@ -1941,7 +1941,8 @@ static void am_resolve(struct am_state *state)
19411941

19421942
if (unmerged_cache()) {
19431943
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."));
19451946
die_user_resolve(state);
19461947
}
19471948

builtin/checkout.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,9 +1259,8 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
12591259
* new_branch && argc > 1 will be caught later.
12601260
*/
12611261
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);
12651264

12661265
if (opts.force_detach)
12671266
die(_("git checkout: --detach does not take a path argument '%s'"),

help.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,8 @@ const char *help_unknown_cmd(const char *cmd)
411411

412412
if (SIMILAR_ENOUGH(best_similarity)) {
413413
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",
416416
n));
417417

418418
for (i = 0; i < n; i++)

0 commit comments

Comments
 (0)