diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2018-02-13 10:32:41 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-02-13 21:01:56 (GMT) |
commit | 4bdd6e7ce33c72dfaa79c4139d30bd809ec8eda7 (patch) | |
tree | a52f7448f4e89c0bbc4ff7e51631db6968a74300 /git-add--interactive.perl | |
parent | 88f6ffc1c256ef241cbed33dabbdd23c1a7ac6a9 (diff) | |
download | git-4bdd6e7ce33c72dfaa79c4139d30bd809ec8eda7.zip git-4bdd6e7ce33c72dfaa79c4139d30bd809ec8eda7.tar.gz git-4bdd6e7ce33c72dfaa79c4139d30bd809ec8eda7.tar.bz2 |
add -p: improve error messages
If the user presses a key that isn't currently active then explain why
it isn't active rather than just listing all the keys. It already did
this for some keys, this patch does the same for the those that
weren't already handled.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'git-add--interactive.perl')
-rwxr-xr-x | git-add--interactive.perl | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 79ab36a..d9d8ff3 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1437,8 +1437,12 @@ sub patch_update_file { } next; } - elsif ($other =~ /g/ && $line =~ /^g(.*)/) { + elsif ($line =~ /^g(.*)/) { my $response = $1; + unless ($other =~ /g/) { + error_msg __("No other hunks to goto\n"); + next; + } my $no = $ix > 10 ? $ix - 10 : 0; while ($response eq '') { $no = display_hunks(\@hunk, $no); @@ -1556,7 +1560,11 @@ sub patch_update_file { next; } } - elsif ($other =~ /s/ && $line =~ /^s/) { + elsif ($line =~ /^s/) { + unless ($other =~ /s/) { + error_msg __("Sorry, cannot split this hunk\n"); + next; + } my @split = split_hunk($hunk[$ix]{TEXT}, $hunk[$ix]{DISPLAY}); if (1 < @split) { print colored $header_color, sprintf( @@ -1568,7 +1576,11 @@ sub patch_update_file { $num = scalar @hunk; next; } - elsif ($other =~ /e/ && $line =~ /^e/) { + elsif ($line =~ /^e/) { + unless ($other =~ /e/) { + error_msg __("Sorry, cannot edit this hunk\n"); + next; + } my $newhunk = edit_hunk_loop($head, \@hunk, $ix); if (defined $newhunk) { splice @hunk, $ix, 1, $newhunk; |