Re: [PATCH v2 1/2] mergetool: don't skip modify/remove conflicts

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v2 1/2] mergetool: don't skip modify/remove conflicts

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:50:33

Martin von Zweigbergk [off-list ref] writes:
quoted hunk
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 081fccc..7b9fe18 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -147,8 +147,6 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 	if (!strcmp(argv[0], "clear")) {
 		for (i = 0; i < merge_rr.nr; i++) {
 			const char *name = (const char *)merge_rr.items[i].util;
-			if (!name)
-				continue;
 			if (!has_rerere_resolution(name))
 				unlink_rr_item(name);
 		}
@@ -157,19 +155,22 @@ int cmd_rerere(int argc, const char **argv, const char *prefix)
 		garbage_collect(&merge_rr);
 	else if (!strcmp(argv[0], "status"))
 		for (i = 0; i < merge_rr.nr; i++) {
-			if (!merge_rr.items[i].util)
-				continue;
 			printf("%s\n", merge_rr.items[i].string);
 		}
-	else if (!strcmp(argv[0], "remaining"))
-		for (i = 0; i < merge_rr.nr; i++)
-			printf("%s\n", merge_rr.items[i].string);
-	else if (!strcmp(argv[0], "diff"))
+	else if (!strcmp(argv[0], "remaining")) {
+		rerere_remaining(&merge_rr);
+		for (i = 0; i < merge_rr.nr; i++) {
+			if (merge_rr.items[i].util != RERERE_RESOLVED)
+				printf("%s\n", merge_rr.items[i].string);
+			else
+				/* prepare for later call to
+				 * string_list_clear() */
+				merge_rr.items[i].util = NULL;
+		}
+	} else if (!strcmp(argv[0], "diff"))
 		for (i = 0; i < merge_rr.nr; i++) {
 			const char *path = merge_rr.items[i].string;
 			const char *name = (const char *)merge_rr.items[i].util;
-			if (!name)
-				continue;
 			diff_two(rerere_path(name, "preimage"), path, path, path);
 		}
 	else
By looking at the diff between the parent of f322b35 (my earlier "rerere
remaining" patch) and the result of applying this patch on top of the
patch, I think the basic idea of this is to correct my stupid mistake of
contaminating merge_rr unconditionally, and instead adding the "remaining"
entries only when handling the "rerere remaining" command (hence many
removal of special cases "if (!name) continue" introduced by my patch.
The result looks _much_ cleaner than the above patch shows and I am happy
with it.

But shouldn't you also revert the parts of my patch to do_plain_rerere()
and rerere_forget() that have similar special cases?

Re: [PATCH v2 1/2] mergetool: don't skip modify/remove conflicts

From: Martin von Zweigbergk <hidden>
Date: 2016-06-15 22:50:33

On Mon, 14 Feb 2011, Junio C Hamano wrote:
But shouldn't you also revert the parts of my patch to do_plain_rerere()
and rerere_forget() that have similar special cases?
Yep, done in patch 2/2.

Your changes in find_conflicts() are still there after patch 1/2 and
since do_plain_rerere() and rerere_forget() call find_conflicts(), I
think they need to check for the punted paths. Only the callers of
setup_rerere() no longer need to care.

In patch 2/2, I refactored a bit more, so that find_conflicts()
behaves the way it did before your first patch, and then the checks
for punted paths are removed from the callers.

If you think the second one is good, it could easily be squashed with
the first one.  I left it separate because I wasn't quite sure. For
example, could the interface to check_one_conflict() be improved? As
you said, part of the changes from your patch are now undone, so I
guess all three patches could even be squashed.


/Martin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help