Thread (21 messages) flat view 21 messages, 3 authors, 2016-06-15

Re: [PATCH 2/4] Teach git-add--interactive to accept a file path to patch

From: Jeff King <hidden>
Date: 2016-06-15 22:43:53
Subsystem: the rest · Maintainer: Linus Torvalds

On Wed, Nov 21, 2007 at 01:36:39PM +0100, Wincent Colaiuta wrote:
If supplied a single file path parameter the git-add--interactive script
now bypasses the command loop and jumps straight to the patch subcommand
using the passed path. After returning from the subcommand the main
command loop is entered. If a non-resolvable path is supplied the
operation is a no-op and the command loop is entered.
Great, the lack of this feature has bugged me in the past. Thank you for
working on it. However...
quoted hunk ↗ jump to hunk
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index fb1e92a..8f21c03 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -803,6 +803,11 @@ sub main_loop {
 	}
 }
 
+die "add --interactive may take only 1 optional parameter" if ($#ARGV > 0);
 refresh();
+if ($#ARGV == 0) {
+	patch_update_file($ARGV[0]);
+}
 status_cmd();
 main_loop();
+
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();

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).

And at any rate, this would require fixing 3/4 to handle the multiple
files from git-add.

What do you think?

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help