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

Re: rerere fails to record resolution if file doesn't exist in merge base

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2007, 08:22 UTC
Message-ID
<7vps32ugu2.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070709070725.GA4445@lala>
Uwe Kleine-König  <ukleinek@informatik.uni-freiburg.de> writes:
Show 6 quoted lines
> Anyhow, the failure still exists, even though the original report was
> sent when rerere was still a perl script ...
>
> 	zeisberg@cassiopeia:/tmp/rerere$ git init
> 	Initialized empty Git repository in .git/
> 	zeisberg@cassiopeia:/tmp/rerere$ mkdir .git/rerere

This should be creating .git/rr-cache, but what you said in your message is correct regardless.

> In my eyes the last command should have recorded the resolution for
> lolo, shouldn't it?

I think two-file merge (ancestor did not have it, and you and he added the path differently) is rare enough that it was dropped outside of the radar. A fix would probably be a trivial change to builtin-rerere.c::find_conflict(), I think. While it would still be sane to insist that we do not do rerere for symlinks, and require to have stages #2 and #3, we should be able to drop the requirement to have stage #1. rerere does not use information from there anyway.

Not even compile tested, but something like this should do.
 builtin-rerere.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/builtin-rerere.c b/builtin-rerere.c
index c25b3d5..6ffc43d 100644
--- a/builtin-rerere.c
+++ b/builtin-rerere.c
@@ -168,19 +168,16 @@ static int find_conflict(struct path_list *conflict)
 	int i;
 	if (read_cache() < 0)
 		return error("Could not read index");
-	for (i = 0; i + 2 < active_nr; i++) {
-		struct cache_entry *e1 = active_cache[i];
-		struct cache_entry *e2 = active_cache[i+1];
-		struct cache_entry *e3 = active_cache[i+2];
-		if (ce_stage(e1) == 1 &&
-		    ce_stage(e2) == 2 &&
+	for (i = 0; i+1 < active_nr; i++) {
+		struct cache_entry *e2 = active_cache[i];
+		struct cache_entry *e3 = active_cache[i+1];
+		if (ce_stage(e2) == 2 &&
 		    ce_stage(e3) == 3 &&
-		    ce_same_name(e1, e2) && ce_same_name(e1, e3) &&
-		    S_ISREG(ntohl(e1->ce_mode)) &&
+		    ce_same_name(e2, e3) &&
 		    S_ISREG(ntohl(e2->ce_mode)) &&
 		    S_ISREG(ntohl(e3->ce_mode))) {
-			path_list_insert((const char *)e1->name, conflict);
-			i += 2;
+			path_list_insert((const char *)e2->name, conflict);
+			i++; /* skip over both #2 and #3 */
 		}
 	}
 	return 0;
Previous: Uwe Kleine-KönigNext: Uwe Kleine-König
Message 2 of 6 in “rerere fails to record resolution if file doesn't exist in merge base”
  1. Uwe Kleine-KönigJul 9, 2007
  2. Junio C HamanoJul 9, 2007
  3. Uwe Kleine-KönigJul 9, 2007
  4. Johannes SchindelinJul 9, 2007
  5. rerere: record resolution even if file is not in merge baseJohannes Schindelin, Jul 9, 2007
  6. Uwe Kleine-KönigJul 9, 2007

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.