Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-26 Thread Jeff King
On Thu, Jul 26, 2012 at 10:59:51AM -0700, Junio C Hamano wrote: > > The credential code uses git_terminal_prompt, which actually opens > > /dev/tty directly. So it is probably sane to use for your new prompt, > > but it does not (and should not) rely on isatty. > > I think using git_terminal_prom

Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-26 Thread Junio C Hamano
Jeff King writes: > - isatty(0) check in cmd_revert to set opts.edit automatically. This > one should match merge's behavior. > ... > So I think the only one that could be improved is the one in cmd_revert. Yeah, that matches the result of my grep. Thanks for sanity checking. > The crede

Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-26 Thread Junio C Hamano
Tay Ray Chuan writes: > On Thu, Jul 26, 2012 at 1:57 AM, Junio C Hamano wrote: >> >> Tay Ray Chuan writes: >> >> > If suggestions are available (based on Levenshtein distance) and if the >> > terminal isatty(), present a prompt to the user to select one of the >> > computed suggestions. >> >> T

Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-26 Thread Jeff King
On Fri, Jul 27, 2012 at 01:08:34AM +0800, Tay Ray Chuan wrote: > > Perhaps we should audit "isatty()" calls and replace them with a > > helper function that does this kind of thing consistently in a more > > robust way (my recent favorite is Linus's somewhat anal logic used > > in builtin/merge.c:

Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-26 Thread Tay Ray Chuan
On Thu, Jul 26, 2012 at 1:57 AM, Junio C Hamano wrote: > > Tay Ray Chuan writes: > > > If suggestions are available (based on Levenshtein distance) and if the > > terminal isatty(), present a prompt to the user to select one of the > > computed suggestions. > > The way to determine "If the termin

Re: [PATCH v2 4/4] allow recovery from command name typos

2012-07-25 Thread Junio C Hamano
Tay Ray Chuan writes: > If suggestions are available (based on Levenshtein distance) and if the > terminal isatty(), present a prompt to the user to select one of the > computed suggestions. The way to determine "If the terminal is a tty" used in this patch looks overly dangerous, given that we

[PATCH v2 4/4] allow recovery from command name typos

2012-07-25 Thread Tay Ray Chuan
If suggestions are available (based on Levenshtein distance) and if the terminal isatty(), present a prompt to the user to select one of the computed suggestions. In the case where there is a single suggestion, present the prompt "[Y/n]", such that "" (ie. the default), "y" and "Y" as input leads