X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-add--interactive.perl;h=ca60356d0082123cd1e9572572528d8265be43a3;hb=5786f4fac7afa881a306e2b771a0307e4ee05384;hp=eb11132b23f2da01c71035fe3f5f321b9f09c908;hpb=3f6aff68896f8490e101eb5c4ad8f0fa5b8b67bb;p=git.git diff --git a/git-add--interactive.perl b/git-add--interactive.perl index eb11132b2..ca60356d0 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -800,6 +800,7 @@ y - stage this hunk n - do not stage this hunk a - stage this and all the remaining hunks in the file d - do not stage this hunk nor any of the remaining hunks in the file +g - select a hunk to go to j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk @@ -945,6 +946,9 @@ sub patch_update_file { if ($ix < $num - 1) { $other .= '/J'; } + if ($num > 1) { + $other .= '/g'; + } for ($i = 0; $i < $num; $i++) { if (!defined $hunk[$i]{USE}) { $undecided = 1; @@ -978,6 +982,28 @@ sub patch_update_file { } next; } + elsif ($other =~ /g/ && $line =~ /^g(.*)/) { + my $response = $1; + my $no = $ix > 10 ? $ix - 10 : 0; + while ($response eq '') { + my $extra = ""; + $no = display_hunks(\@hunk, $no); + if ($no < $num) { + $extra = " ( to see more)"; + } + print "go to which hunk$extra? "; + $response = ; + chomp $response; + } + if ($response !~ /^\s*\d+\s*$/) { + print STDERR "Invalid number: '$response'\n"; + } elsif (0 < $response && $response <= $num) { + $ix = $response - 1; + } else { + print STDERR "Sorry, only $num hunks available.\n"; + } + next; + } elsif ($line =~ /^d/i) { while ($ix < $num) { if (!defined $hunk[$ix]{USE}) {