Suggestion for the "Did you mean this?" feature
Hello all,
I have found the "Did you mean this?" feature of git as a very good feature. I thought it would be even better if it took a step toward by asking for a prompt when there was only one alternative to the command that was entered.
E.g.
Quoted 10 lines
unique@unique-pc:~$ git hepl git: 'hepl' is not a git command. See 'git --help'.Did you mean this?
help
[yes/No] : y
usage: git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info- path]
....
This would make it even better for the user as it would avoid having to correct the mistake long commands that had only a single error (considering history feature is enabled).
Is this is a good idea ?
Signature · 2 lines
Regards, Kaartic
Hi,
Quoted 18 lines · Kaartic Sivaraam
I have found the "Did you mean this?" feature of git as a very good feature. I thought it would be even better if it took a step toward by asking for a prompt when there was only one alternative to the command that was entered.
E.g.
Quoted 10 lines
unique@unique-pc:~$ git hepl git: 'hepl' is not a git command. See 'git --help'.Did you mean this?
help
[yes/No] : y
usage: git [--version] [--help] [-C <path>] [-c name=value][--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
....
Quoted 5 lines
This would make it even better for the user as it would avoid having to correct the mistake long commands that had only a single error (considering history feature is enabled).
Is this is a good idea ?
I cannot tell if this is a good idea (or why it would be a bad idea) but why do you restrict your suggestion to the case when there is only one alternative?
Why not also something like:
---
$ git sta git: 'sta' is not a git command. See 'git --help'.
Did you mean one of these?
[1] status [2] stage [3] stash
You can choose or quit [1,2,3,q]:
---
Best
Stephan
Quoted 9 lines · Stephan Beyer
I cannot tell if this is a good idea (or why it would be a bad idea) but
why do you restrict your suggestion to the case when there is only one
alternative?Why not also something like:
---
Quoted 8 lines
$ git sta git: 'sta' is not a git command. See 'git --help'.Did you mean one of these?
[1] status [2] stage [3] stashYou can choose or quit [1,2,3,q]:
That would be fine too. Just thought it would be a good start to start with a simple case. Also, I wasn't sure if there were any drawback's that I was missing. I guess if it was implemented it wouldn't be difficult to extend it further.
Signature · 2 lines
Regards, Kaartic
Quoted 20 lines · Kaartic Sivaraam
Hello all,
I have found the "Did you mean this?" feature of git as a very good feature. I thought it would be even better if it took a step toward by asking for a prompt when there was only one alternative to the command that was entered.
E.g.
Quoted 10 lines
unique@unique-pc:~$ git hepl git: 'hepl' is not a git command. See 'git --help'.Did you mean this?
help
[yes/No] : y
usage: git [--version] [--help] [-C <path>] [-c name=value][--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
....
Quoted 5 lines
This would make it even better for the user as it would avoid having to correct the mistake long commands that had only a single error (considering history feature is enabled).
Is this is a good idea ?
It's definitely a good thing for human users. For example, I am annoyed from time to time when I type in some long spell, mistype one minor thing, and the whole command fails. Then I need to press <up>, correct the obvious typo, and run the command again.
Though, there is one aspect which may be the reason why git does not have this feature: it requires interactive input. For example, it won't work if some script tries to run an invalid git command. And git cannot really tell whether it is running interactively or in a batch mode. If it is running in batch mode then the whole script may hang indefinitely waiting for nonexistent input. This also may apply to using git with pipes.
Maybe a configuration option or some GIT_NO_PROMPT environment variable may be used to force disable this, but it still will be a hassle for the scripts.
Quoted 20 lines · Kaartic Sivaraam
Hello all,
I have found the "Did you mean this?" feature of git as a very good feature. I thought it would be even better if it took a step toward by asking for a prompt when there was only one alternative to the command that was entered.
E.g.
Quoted 10 lines
unique@unique-pc:~$ git hepl git: 'hepl' is not a git command. See 'git --help'.Did you mean this?
help
[yes/No] : y
usage: git [--version] [--help] [-C <path>] [-c name=value][--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
....
Quoted 5 lines
This would make it even better for the user as it would avoid having to correct the mistake long commands that had only a single error (considering history feature is enabled).
Is this is a good idea ?
This feature already exists (although it's not interactive). See help.autoCorrect in the git-config man page. "git config help.autoCorrect -1" should to the trick.
PATCH 1/1 Tweak help auto-correct phrasing.
---
Quoted 4 lines · Chris Packham
This feature already exists (although it's not interactive). See help.autoCorrect in the git-config man page. "git config help.autoCorrect -1" should to the trick.
Awesome, I was unaware of this feature. Thanks!
I found the message it prints a bit awkward, so here's a patch to fix it up.
Instead of:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
in 1.5 seconds automatically...
it's now:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing in 1.5 seconds under the assumption that you meant 'log'.
M.
help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
help.c +12 -6
@@ -381,12 +381,18 @@ const char *help_unknown_cmd(const char *cmd)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 under the " +"assumption that you meant '%s'." ), + (float )autocorrect/10.0 , assumed);sleep_millisec (autocorrect *100 ); }return assumed;
Signature · 1 line
2.11.0.dirty
Re: [PATCH] Tweak help auto-correct phrasing.
Quoted 19 lines · Marc Branchaud
Signed-off-by Marc Branchaud <[email protected]>---
Quoted 4 lines · Chris Packham
This feature already exists (although it's not interactive). See help.autoCorrect in the git-config man page. "git config help.autoCorrect -1" should to the trick.
Awesome, I was unaware of this feature. Thanks!
I found the message it prints a bit awkward, so here's a patch to fix it up.
Instead of:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
in 1.5 seconds automatically...
Quoted 6 lines
it's now:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing in 1.5 seconds under the assumption that you meant 'log'.
M.
Sounds better.
The "Instead of ... we now show ..." description deserves to be in the log message, not after "---" line.
s/under the assumption/assuming/ would make it even shorter and give the potentially long corrected command name a chance to still fit on the line without wrapping, I would think, though.
Quoted 33 lines
help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)help.c +12
-6@@ -381,12 +381,18 @@ const char *help_unknown_cmd(const char *cmd)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 under the " +"assumption that you meant '%s'." ), + (float )autocorrect/10.0 , assumed);sleep_millisec (autocorrect *100 ); }return assumed;
PATCH v2 1/1 Tweak help auto-correct phrasing.
When auto-correct is enabled, an invalid git command prints a warning and a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
in 1.5 seconds automatically...
With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
The continuation message's phrasing is awkward. This commit cleans it up. As a bonus, we now use full-sentence strings which make translation easier.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing in 1.5 seconds, assuming that you meant 'log'.
With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'.
---
Writing the commit message was more work than the commit! :)
M.
help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
help.c +12 -6
@@ -381,12 +381,18 @@ const char *help_unknown_cmd(const char *cmd)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;
Signature · 1 line
2.11.0.1.g75fa99b
Re: [PATCHv2] Tweak help auto-correct phrasing.
Quoted 29 lines · Marc Branchaud
When auto-correct is enabled, an invalid git command prints a warning and
a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log' in 1.5 seconds automatically...With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log'The continuation message's phrasing is awkward. This commit cleans it up.
As a bonus, we now use full-sentence strings which make translation easier.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing in 1.5 seconds, assuming that you meant 'log'.
Quoted 9 lines
With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log'.Signed-off-by Marc Branchaud <[email protected]>---
Excuse me for bringing this up after a long time. What's the status of this patch? Was it applied?
Signature · 2 lines
Regards, Kaartic Sivaraam <[email protected]>
Re: [PATCHv2] Tweak help auto-correct phrasing.
Quoted 36 lines · Kaartic Sivaraam
Quoted 35 lines · Marc Branchaud
When auto-correct is enabled, an invalid git command prints a warning and
a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not
exist.
Continuing under the assumption that you meant 'log' in 1.5 seconds automatically...With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not
exist.
Continuing under the assumption that you meant 'log'The continuation message's phrasing is awkward. This commit cleans it up.
As a bonus, we now use full-sentence strings which make translation easier.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not
exist.
Continuing in 1.5 seconds, assuming that you meant 'log'.With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not
exist.
Continuing under the assumption that you meant 'log'.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Marc Branchaud <[email protected]>---
Excuse me for bringing this up after a long time. What's the status of this patch? Was it applied?
Looks like it got lost in the shuffle.
The topic thread starts at:
http://public-inbox.org/git/[email protected]/
There's no reply to my v2 patch, and I neglected to follow up on it -- sorry!
Shall I resend the patch?
M.
PATCH v2 1/1 Tweak help auto-correct phrasing.
When auto-correct is enabled, an invalid git command prints a warning and a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
in 1.5 seconds automatically...
With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
The continuation message's phrasing is awkward. This commit cleans it up. As a bonus, we now use full-sentence strings which make translation easier.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing in 1.5 seconds, assuming that you meant 'log'.
With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'.
---
So here's the patch again.
M.
help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
help.c +12 -6
@@ -356,12 +356,18 @@ const char *help_unknown_cmd(const char *cmd)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;
Signature · 1 line
2.13.1.388.g69e6b9b4f.dirty
Re: [PATCHv2 (resend)] Tweak help auto-correct phrasing.
Quoted 25 lines · Marc Branchaud
When auto-correct is enabled, an invalid git command prints a warning and a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
in 1.5 seconds automatically...With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'
The continuation message's phrasing is awkward. This commit cleans it up. As a bonus, we now use full-sentence strings which make translation easier.
With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist. Continuing in 1.5 seconds, assuming that you meant 'log'.
With help.autoCorrect < 0:
Quoted 7 lines
WARNING: You called a Git command named 'lgo', which does not exist. Continuing under the assumption that you meant 'log'.
Signed-off-by Marc Branchaud <[email protected]>---
So here's the patch again.
Thanks. Will queue and wait for people to yell at us when this breaks their setup (which I highly doubt would happen ;-).
Quoted 32 lines
help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)help.c +12
-6@@ -356,12 +356,18 @@ const char *help_unknown_cmd(const char *cmd)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;
Re: [PATCHv2] Tweak help auto-correct phrasing.
In reply to Marc BranchaudQuoted 76 lines · Marc Branchaud
When auto-correct is enabled, an invalid git command prints a warning and
a continuation message, which differs depending on whether or not help.autoCorrect is positive or negative.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log' in 1.5 seconds automatically...With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log'The continuation message's phrasing is awkward. This commit cleans it up.
As a bonus, we now use full-sentence strings which make translation easier.With help.autoCorrect = 15:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing in 1.5 seconds, assuming that you meant 'log'.With help.autoCorrect < 0:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log'.Signed-off-by Marc Branchaud <[email protected]>---
Writing the commit message was more work than the commit! :)
M.help.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)help.c +0
-0@@ -381,12 +381,18 @@ const char *help_unknown_cmd(const char *cmd) clean_cmdnames(&main_cmds); fprintf_ln(stderr,_("WARNING: You called a Git command named '%s', "
help.c +0
-2- "which does not exist.\n" - "Continuing under the assumption thatyou meant '%s'"),
help.c +0
-3- cmd, assumed); -if (autocorrect >0 ) { - fprintf_ln(stderr, _("in %0.1f secondsautomatically..."),
help.c +5
-1- (float)autocorrect/10.0); + "which does not exist."), + cmd); +if (autocorrect <0 ) + fprintf_ln(stderr, + _("Continuing under theassumption that "
help.c +6
-0+ "you meant '%s'."), + assumed); + else { + fprintf_ln(stderr, + _("Continuing in %0.1f seconds, " + "assuming that you meant'%s'."),
help.c +1
-0+ (float)autocorrect/10.0,
Quoted 4 lines
assumed);
sleep_millisec(autocorrect * 100); }
return assumed;
Excuse me bringing this up after a long time. Was this patch applied? What's it's status?
Signature · 2 lines
Regards, Kaartic Sivaraam <[email protected]>
Hello all,
On Sun, 18 December 2016 at 20:59, Alexei Lozovsky wrote,
Quoted 18 lines
It's definitely a good thing for human users. For example, I am annoyed
from time to time when I type in some long spell, mistype one minor thing,
and the whole command fails. Then I need to press <up>, correct the obvious typo, and run the command again.Though, there is one aspect which may be the reason why git does not have
this feature: it requires interactive input. For example, it won't work
if some script tries to run an invalid git command. And git cannot really
tell whether it is running interactively or in a batch mode. If it is running in batch mode then the whole script may hang indefinitely waiting
for nonexistent input. This also may apply to using git with pipes.
Quoted 5 lines
Maybe a configuration option or some
GIT_NO_PROMPTenvironment variable
may be used to force disable this, but it still will be a hassle for the
scripts.
This is a good point that I didn't think of, sir. Thanks for bringing it up. It seems that in some other form git does have the feature I was suggesting.
Quoted 3 lines · Chris Packham
This feature already exists (although it's not interactive). See help.autoCorrect in the git-config man page. "git config help.autoCorrect -1" should to the trick.
Thanks for bringing this to notice, sir. I wasn't aware of it before. It's in essence the same feature.
Quoted 13 lines · Marc Branchaud
Signed-off-by Marc Branchaud <[email protected]>---
Awesome, I was unaware of this feature. Thanks!
I found the message it prints a bit awkward, so here's a patch to fix it up.
Instead of:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing under the assumption that you meant 'log'
Quoted 8 lines
in 1.5 seconds automatically...
it's now:
WARNING: You called a Git command named 'lgo', which does not exist.
Continuing in 1.5 seconds under the assumption that you meant 'log'.
Happy that my mail introduced a little change to git by revealing a not often used feature.
Signature · 2 lines
Regards, Kaartic