git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Erik Faye-Lund <kusmabite@gmail.com>
Cc: git@vger.kernel.org, matthieu.moy@grenoble-inp.fr, hellmuth@ira.uka.de
Subject: Re: [PATCH] add -p: skip conflicted paths
Date: Wed, 28 Mar 2012 15:14:31 -0700	[thread overview]
Message-ID: <7v62dotltk.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vaa30tmk9.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 28 Mar 2012 14:58:30 -0700")

Junio C Hamano <gitster@pobox.com> writes:

>> Totally untested, but something along this line...
>
> Well, probably along that line but not there.  I think the patch would be
> a lot cleaner to keep the part I touched intact, and instead add an extra
> "ls-files -u" that creates %unmerged hash in the way this patch does,
> immediately before the last for() loop in the function.  And then the loop
> can use %unmerged hash to filter the elements.

That is, something like this.

 git-add--interactive.perl |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 8f0839d..ddb2e77 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, $filter_unmerged) = @_;
 	my (%data, @return);
 	my ($add, $del, $adddel, $file);
 	my @tracked = ();
@@ -348,9 +348,26 @@ sub list_modified {
 		}
 	}
 
+	my %unmerged;
+	if ($filter_unmerged) {
+		for (run_cmd_pipe(qw(git ls-files -u --), @ARGV)) {
+			chomp $_;
+			if (/^[0-7]+ [0-9a-f]{40} [0-3]	(.*)/) {
+				my $path = unquote_path($1);
+				$unmerged{$path} = 1;
+			}
+		}
+		if (%unmerged) {
+			for (sort keys %unmerged) {
+				print colored $error_color, "ignoring unmerged: $_\n";
+			}
+		}
+	}
+
 	for (sort keys %data) {
-		my $it = $data{$_};
+		next if exists $unmerged{$_};
 
+		my $it = $data{$_};
 		if ($only) {
 			if ($only eq 'index-only') {
 				next if ($it->{INDEX} eq 'unchanged');
@@ -1189,7 +1206,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}, 'filter-unmerged');
 	my @mods = grep { !($_->{BINARY}) } @all_mods;
 	my @them;
 

  reply	other threads:[~2012-03-28 22:14 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-28 19:18 [PATCH] add -p: skip conflicted paths Erik Faye-Lund
2012-03-28 19:28 ` Junio C Hamano
2012-03-28 20:20   ` Erik Faye-Lund
2012-03-28 21:39     ` Junio C Hamano
2012-03-28 21:58       ` Junio C Hamano
2012-03-28 22:14         ` Junio C Hamano [this message]
2012-03-29  5:45           ` Jeff King
2012-04-02 17:20             ` Erik Faye-Lund
2012-04-02 18:25               ` Junio C Hamano
2012-04-04  9:46                 ` Jeff King
2012-04-04 12:50                   ` Tay Ray Chuan
2012-04-04 15:36                   ` Junio C Hamano
2012-04-04 18:29                     ` Junio C Hamano
2012-04-04 20:25                       ` Jeff King
2012-04-04 21:31                         ` Junio C Hamano
2012-04-05 12:30                           ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v62dotltk.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=hellmuth@ira.uka.de \
    --cc=kusmabite@gmail.com \
    --cc=matthieu.moy@grenoble-inp.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).