[PATCH] add -p: skip conflicted paths

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]