From: Wincent Colaiuta Date: Wed, 21 Nov 2007 16:15:59 GMT Subject: Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch Message-ID: In-Reply-To: <20071121152118.GG24108@sigill.intra.peff.net> El 21/11/2007, a las 16:21, Jeff King escribió: > On Wed, Nov 21, 2007 at 01:36:39PM +0100, Wincent Colaiuta wrote: > >> +if ($#ARGV == 0) { >> + patch_update_file($ARGV[0]); >> +} > > Why only one file? How about something like this instead: > > diff --git a/git-add--interactive.perl b/git-add--interactive.perl > index fb1e92a..8036c95 100755 > --- a/git-add--interactive.perl > +++ b/git-add--interactive.perl > @@ -804,5 +804,8 @@ sub main_loop { > } > > refresh(); > +foreach my $file (@ARGV) { > + patch_update_file($file); > +} > status_cmd(); > main_loop(); Yes, that makes sense. I wasn't sure how to handle multiple files, but I guess just looping through them is fine. > On top of that, it would be great to be able to do something like > > git-add -i *.c > > and just get prompted for changed files (right now, you only get > prompted for changed files, but unchanged files seem to print a > spurious > newline). That spurious newline comes from the last line of the patch_update_file function (previously named patch_update_cmd): print "\n"; The solution will be to do an early return, printing nothing for those unchanged files (and same thing for untracked files). Will look into it. > And at any rate, this would require fixing 3/4 to handle the multiple > files from git-add. > > What do you think? Should have some time later this evening or tomorrow to incorporate your suggestions. Cheers, Wincent