Subject: Re: [PATCH/RFC v3] git add -i: Answer questions with a single keypress

From: "Suraj N. Kurapati" <[email-masked]>
Date: Thu, 6 Nov 2008 08:15:16 -0800

On Thursday 06 November 2008 00:42:36 Jeff King wrote:
> On Wed, Nov 05, 2008 at 09:59:25AM -0800, Suraj N. Kurapati wrote:
> > Allows the user to answer 'Stage this hunk' questions with a
> > single keypress, just like in Darcs.  Previously, the user was
> > forced to press the Return key after every choice they made.
> > This quickly becomes tiring, burdensome work for the fingers.
>
> I think this is a reasonable goal, but I have a few questions/concerns.
>
>  - There are three versions of your patch, but nobody has commented.
>    Clearly we can see what changed, but it is not clear what advantage
>    one patch has over the other. Care to elaborate?

v1 and v2 make the mistake of setting raw mode, which prevent the user from 
pressing Control-C to exit the program.  v3 fixes this by using cbreak mode.

>  - Term::ReadKey, while common, is not part of base perl. So I think
>    using it needs to be conditional, and on systems without it we can
>    degrade to the current behavior.

The git-svn.perl script also uses Term::ReadKey.  Since it is already in the 
git source repository, I thought it was okay to use Term::ReadKey.

>  - There's no facility in your patch for restoring the terminal if we
>    break out of the loop in an unexpected way (e.g., via the user
>    hitting ^C).

Good point.  I'll try to address this in a v4 patch.

>  - This only enhances one particular input, the patch loop. It is
>    probably worth being consistent and allowing these behavior for other
>    menus (though the numeric inputs are a bit trickier).

Understood.