* Suggestion for the "Did you mean this?" feature
@ 2016-12-18 12:18 Kaartic Sivaraam
2016-12-18 13:16 ` Stephan Beyer
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Kaartic Sivaraam @ 2016-12-18 12:18 UTC (permalink / raw)
To: git
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.
> 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 ?
--
Regards,
Kaartic
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Suggestion for the "Did you mean this?" feature 2016-12-18 12:18 Suggestion for the "Did you mean this?" feature Kaartic Sivaraam @ 2016-12-18 13:16 ` Stephan Beyer 2016-12-18 13:26 ` Kaartic Sivaraam 2016-12-18 15:16 ` Alexei Lozovsky 2016-12-19 0:48 ` Chris Packham 2 siblings, 1 reply; 14+ messages in thread From: Stephan Beyer @ 2016-12-18 13:16 UTC (permalink / raw) To: Kaartic Sivaraam, git Hi, On 12/18/2016 01:18 PM, Kaartic Sivaraam wrote: > 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. > >> 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 ? 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 ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Suggestion for the "Did you mean this?" feature 2016-12-18 13:16 ` Stephan Beyer @ 2016-12-18 13:26 ` Kaartic Sivaraam 0 siblings, 0 replies; 14+ messages in thread From: Kaartic Sivaraam @ 2016-12-18 13:26 UTC (permalink / raw) To: Stephan Beyer, git On Sun, 2016-12-18 at 14:16 +0100, Stephan Beyer wrote: > 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]: 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. -- Regards, Kaartic ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Suggestion for the "Did you mean this?" feature 2016-12-18 12:18 Suggestion for the "Did you mean this?" feature Kaartic Sivaraam 2016-12-18 13:16 ` Stephan Beyer @ 2016-12-18 15:16 ` Alexei Lozovsky 2016-12-19 0:48 ` Chris Packham 2 siblings, 0 replies; 14+ messages in thread From: Alexei Lozovsky @ 2016-12-18 15:16 UTC (permalink / raw) To: Kaartic Sivaraam; +Cc: git On 18 December 2016 at 14:18, Kaartic Sivaraam wrote: > 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. > >> 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 ? 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. ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Suggestion for the "Did you mean this?" feature 2016-12-18 12:18 Suggestion for the "Did you mean this?" feature Kaartic Sivaraam 2016-12-18 13:16 ` Stephan Beyer 2016-12-18 15:16 ` Alexei Lozovsky @ 2016-12-19 0:48 ` Chris Packham 2016-12-19 17:01 ` [PATCH] Tweak help auto-correct phrasing Marc Branchaud 2016-12-19 19:24 ` Suggestion for the "Did you mean this?" feature Kaartic Sivaraam 2 siblings, 2 replies; 14+ messages in thread From: Chris Packham @ 2016-12-19 0:48 UTC (permalink / raw) To: Kaartic Sivaraam; +Cc: GIT On Mon, Dec 19, 2016 at 1:18 AM, Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> wrote: > 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. > >> 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 ? 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. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] Tweak help auto-correct phrasing. 2016-12-19 0:48 ` Chris Packham @ 2016-12-19 17:01 ` Marc Branchaud 2016-12-19 22:04 ` Junio C Hamano 2016-12-19 19:24 ` Suggestion for the "Did you mean this?" feature Kaartic Sivaraam 1 sibling, 1 reply; 14+ messages in thread From: Marc Branchaud @ 2016-12-19 17:01 UTC (permalink / raw) To: git; +Cc: Kaartic Sivaraam, Chris Packham, Alex Riesen Signed-off-by: Marc Branchaud <marcnarc@xiplink.com> --- On 2016-12-18 07:48 PM, Chris Packham wrote: > > 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(-) diff --git a/help.c b/help.c index 53e2a67e00..55350c0673 100644 --- a/help.c +++ b/help.c @@ -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; -- 2.11.0.dirty ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] Tweak help auto-correct phrasing. 2016-12-19 17:01 ` [PATCH] Tweak help auto-correct phrasing Marc Branchaud @ 2016-12-19 22:04 ` Junio C Hamano 2016-12-20 14:02 ` [PATCHv2] " Marc Branchaud 0 siblings, 1 reply; 14+ messages in thread From: Junio C Hamano @ 2016-12-19 22:04 UTC (permalink / raw) To: Marc Branchaud; +Cc: git, Kaartic Sivaraam, Chris Packham, Alex Riesen Marc Branchaud <marcnarc@xiplink.com> writes: > Signed-off-by: Marc Branchaud <marcnarc@xiplink.com> > --- > > On 2016-12-18 07:48 PM, Chris Packham wrote: >> >> 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. 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. > > help.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/help.c b/help.c > index 53e2a67e00..55350c0673 100644 > --- a/help.c > +++ b/help.c > @@ -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; ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCHv2] Tweak help auto-correct phrasing. 2016-12-19 22:04 ` Junio C Hamano @ 2016-12-20 14:02 ` Marc Branchaud 2017-06-20 18:00 ` Kaartic Sivaraam 2017-06-20 18:04 ` Kaartic Sivaraam 0 siblings, 2 replies; 14+ messages in thread From: Marc Branchaud @ 2016-12-20 14:02 UTC (permalink / raw) To: git; +Cc: Kaartic Sivaraam, Chris Packham, Alex Riesen, Junio C Hamano 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 <marcnarc@xiplink.com> --- Writing the commit message was more work than the commit! :) M. help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/help.c b/help.c index 53e2a67e00..fc56aa2d76 100644 --- a/help.c +++ b/help.c @@ -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; -- 2.11.0.1.g75fa99b ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCHv2] Tweak help auto-correct phrasing. 2016-12-20 14:02 ` [PATCHv2] " Marc Branchaud @ 2017-06-20 18:00 ` Kaartic Sivaraam 2017-06-20 18:04 ` Kaartic Sivaraam 1 sibling, 0 replies; 14+ messages in thread From: Kaartic Sivaraam @ 2017-06-20 18:00 UTC (permalink / raw) To: Marc Branchaud, git; +Cc: Chris Packham, Alex Riesen, Junio C Hamano On Tue, 2016-12-20 at 09:02 -0500, Marc Branchaud wrote: > 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 <marcnarc@xiplink.com> > --- > > Writing the commit message was more work than the commit! :) > > M. > > help.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/help.c b/help.c > index 53e2a67e00..fc56aa2d76 100644 > --- a/help.c > +++ b/help.c > @@ -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; Excuse me bringing this up after a long time. Was this patch applied? What's it's status? -- Regards, Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2] Tweak help auto-correct phrasing. 2016-12-20 14:02 ` [PATCHv2] " Marc Branchaud 2017-06-20 18:00 ` Kaartic Sivaraam @ 2017-06-20 18:04 ` Kaartic Sivaraam 2017-06-20 18:21 ` Marc Branchaud 1 sibling, 1 reply; 14+ messages in thread From: Kaartic Sivaraam @ 2017-06-20 18:04 UTC (permalink / raw) To: Marc Branchaud, git; +Cc: Chris Packham, Alex Riesen, Junio C Hamano On Tue, 2016-12-20 at 09:02 -0500, Marc Branchaud wrote: > 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 <marcnarc@xiplink.com> > --- > Excuse me for bringing this up after a long time. What's the status of this patch? Was it applied? -- Regards, Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCHv2] Tweak help auto-correct phrasing. 2017-06-20 18:04 ` Kaartic Sivaraam @ 2017-06-20 18:21 ` Marc Branchaud 2017-06-21 13:57 ` [PATCHv2 (resend)] " Marc Branchaud 0 siblings, 1 reply; 14+ messages in thread From: Marc Branchaud @ 2017-06-20 18:21 UTC (permalink / raw) To: Kaartic Sivaraam, git; +Cc: Chris Packham, Alex Riesen, Junio C Hamano On 2017-06-20 02:04 PM, Kaartic Sivaraam wrote: > On Tue, 2016-12-20 at 09:02 -0500, Marc Branchaud wrote: >> 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 <marcnarc@xiplink.com> >> --- >> > 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/1482063500.10858.1.camel@gmail.com/ There's no reply to my v2 patch, and I neglected to follow up on it -- sorry! Shall I resend the patch? M. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCHv2 (resend)] Tweak help auto-correct phrasing. 2017-06-20 18:21 ` Marc Branchaud @ 2017-06-21 13:57 ` Marc Branchaud 2017-06-21 22:34 ` Junio C Hamano 0 siblings, 1 reply; 14+ messages in thread From: Marc Branchaud @ 2017-06-21 13:57 UTC (permalink / raw) To: Kaartic Sivaraam; +Cc: Chris Packham, Alex Riesen, Junio C Hamano, git 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 <marcnarc@xiplink.com> --- So here's the patch again. M. help.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/help.c b/help.c index f637fc800..69966c174 100644 --- a/help.c +++ b/help.c @@ -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; -- 2.13.1.388.g69e6b9b4f.dirty ^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCHv2 (resend)] Tweak help auto-correct phrasing. 2017-06-21 13:57 ` [PATCHv2 (resend)] " Marc Branchaud @ 2017-06-21 22:34 ` Junio C Hamano 0 siblings, 0 replies; 14+ messages in thread From: Junio C Hamano @ 2017-06-21 22:34 UTC (permalink / raw) To: Marc Branchaud; +Cc: Kaartic Sivaraam, Chris Packham, Alex Riesen, git Marc Branchaud <marcnarc@xiplink.com> writes: > 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 <marcnarc@xiplink.com> > --- > > 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 ;-). > help.c | 18 ++++++++++++------ > 1 file changed, 12 insertions(+), 6 deletions(-) > > diff --git a/help.c b/help.c > index f637fc800..69966c174 100644 > --- a/help.c > +++ b/help.c > @@ -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; ^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: Suggestion for the "Did you mean this?" feature 2016-12-19 0:48 ` Chris Packham 2016-12-19 17:01 ` [PATCH] Tweak help auto-correct phrasing Marc Branchaud @ 2016-12-19 19:24 ` Kaartic Sivaraam 1 sibling, 0 replies; 14+ messages in thread From: Kaartic Sivaraam @ 2016-12-19 19:24 UTC (permalink / raw) To: Chris Packham; +Cc: GIT Hello all, On Sun, 18 December 2016 at 20:59, Alexei Lozovsky wrote, > 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. 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. On Mon, 2016-12-19 at 13:48 +1300, Chris Packham wrote: > 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. On Mon, 2016-12-19 at 12:01 -0500, Marc Branchaud wrote: > Signed-off-by: Marc Branchaud <marcnarc@xiplink.com> > --- > > 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'. Happy that my mail introduced a little change to git by revealing a not often used feature. -- Regards, Kaartic ^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2017-06-21 22:34 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-12-18 12:18 Suggestion for the "Did you mean this?" feature Kaartic Sivaraam 2016-12-18 13:16 ` Stephan Beyer 2016-12-18 13:26 ` Kaartic Sivaraam 2016-12-18 15:16 ` Alexei Lozovsky 2016-12-19 0:48 ` Chris Packham 2016-12-19 17:01 ` [PATCH] Tweak help auto-correct phrasing Marc Branchaud 2016-12-19 22:04 ` Junio C Hamano 2016-12-20 14:02 ` [PATCHv2] " Marc Branchaud 2017-06-20 18:00 ` Kaartic Sivaraam 2017-06-20 18:04 ` Kaartic Sivaraam 2017-06-20 18:21 ` Marc Branchaud 2017-06-21 13:57 ` [PATCHv2 (resend)] " Marc Branchaud 2017-06-21 22:34 ` Junio C Hamano 2016-12-19 19:24 ` Suggestion for the "Did you mean this?" feature Kaartic Sivaraam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).