Re: Suggestion for the "Did you mean this?" feature

2016-12-19 Thread Kaartic Sivaraam
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 , 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 
> ---
> 
> 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


Re: Suggestion for the "Did you mean this?" feature

2016-12-18 Thread Chris Packham
On Mon, Dec 19, 2016 at 1:18 AM, 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 ] [-c name=value]
>>[--exec-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.


Re: Suggestion for the "Did you mean this?" feature

2016-12-18 Thread Alexei Lozovsky
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 ] [-c name=value]
>>[--exec-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 , 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.


Re: Suggestion for the "Did you mean this?" feature

2016-12-18 Thread Kaartic Sivaraam
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


Re: Suggestion for the "Did you mean this?" feature

2016-12-18 Thread Stephan Beyer
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 ] [-c name=value]
>>[--exec-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