git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] add -p: skip conflicted paths

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 28, 2012, 22:14 UTC
Message-ID
<7v62dotltk.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vaa30tmk9.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 7 quoted lines
>> 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;
 
Previous: Junio C HamanoNext: Jeff King
Message 6 of 16 in “add -p: skip conflicted paths”
  1. add -p: skip conflicted pathsErik Faye-Lund, Mar 28, 2012
  2. Junio C HamanoMar 28, 2012
  3. add -p: skip conflicted pathsErik Faye-Lund, Mar 28, 2012
  4. Junio C HamanoMar 28, 2012
  5. Junio C HamanoMar 28, 2012
  6. Junio C HamanoMar 28, 2012
  7. Jeff KingMar 29, 2012
  8. Erik Faye-LundApr 2, 2012
  9. Junio C HamanoApr 2, 2012
  10. Jeff KingApr 4, 2012
  11. Tay Ray ChuanApr 4, 2012
  12. Junio C HamanoApr 4, 2012
  13. Junio C HamanoApr 4, 2012
  14. Jeff KingApr 4, 2012
  15. Junio C HamanoApr 4, 2012
  16. Jeff KingApr 5, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.