[PATCH] add -p: skip conflicted paths
- From
Erik Faye-Lund <kusmabite@gmail.com>
- Date
- Mar 28, 2012, 19:18 UTC
- Message-ID
- <1332962282-4040-1-git-send-email-kusmabite@gmail.com>
When performing "git add -p" on a file in a conflicted state, we currently spew the diff and terminate the process.
This is not very helpful to the user. Change the behaviour to skipping the file, while outputting a warning.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com> ---
OK, here's a quick stab at fixing the "add -p" issue. Note that I'm not very fluent in Perl, so apologies if this is not up to standards.
git-add--interactive.perl | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl index 8f0839d..a52507f 100755 --- a/git-add--interactive.perl +++ b/git-add--interactive.perl @@ -1259,6 +1259,13 @@ sub patch_update_file { my $quit = 0; my ($ix, $num); my $path = shift; + + # skip conflicted paths + if (run_cmd_pipe(qw(git ls-files -u --), $path)) { + print colored $error_color, "Warning: $path is in conflicted state, skipping.\n"; + return 0; + } + my ($head, @hunk) = parse_diff($path); ($head, my $mode, my $deletion) = parse_diff_header($head); for (@{$head->{DISPLAY}}) {
-- 1.7.9