[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>
---

On Wed, Mar 28, 2012 at 9:28 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Perhaps teach list_modified(), which currently takes 'file-only' and
> 'index-only', to also take an option to omit (and warn if it is
> appropriate) unmerged paths?

Good idea. This way, the path doesn't even get listed when using
git add -i, and no warning is spewed on "git add -p" without specifying
the path. It seems like the right thing to do.

Again, I'm no Perl-guru, so apologies if the code isn't idiomatic.

 git-add--interactive.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8f0839d..4913203 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -270,7 +270,7 @@ sub get_empty_tree {
 # FILE_ADDDEL:	is it add/delete between index and file?
 
 sub list_modified {
-	my ($only) = @_;
+	my ($only, $omit_unmerged) = @_;
 	my (%data, @return);
 	my ($add, $del, $adddel, $file);
 	my @tracked = ();
@@ -359,6 +359,10 @@ sub list_modified {
 				next if ($it->{FILE} eq 'nothing');
 			}
 		}
+		if ($omit_unmerged && run_cmd_pipe(qw(git ls-files -u --), $_)) {
+			print colored $error_color, "Warning: $_ is in conflicted state, skipping.\n" if @ARGV;
+			next;
+		}
 		push @return, +{
 			VALUE => $_,
 			%$it,
@@ -1189,7 +1193,7 @@ sub apply_patch_for_checkout_commit {
 }
 
 sub patch_update_cmd {
-	my @all_mods = list_modified($patch_mode_flavour{FILTER});
+	my @all_mods = list_modified($patch_mode_flavour{FILTER}, 1);
 	my @mods = grep { !($_->{BINARY}) } @all_mods;
 	my @them;
 
-- 
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]