Subject: Re: [PATCH v2] Add note that conflict resolution is still performed

From: Junio C Hamano <[email-masked]>
Date: Fri, 15 Jul 2022 14:50:12 -0700

Junio C Hamano <[email-masked]> writes:

> A tangent that may be worth thinking about, that does not have to be
> part of this topic (as it probably will involve code change).
>
> It makes sense that "--no-rerere-autoupdate" does not disable the
> "rerere" mechanism (when it is enabled, of course), because it makes
> sense to reuse recorded resolution without updating the index with
> the result.
>
> However, it may make sense to have "--rerere-autoupdate" option to
> enable the "rerere" mechanism when it is disabled, because with
> "rerere" disabled, there is nothing to auto-update.

I think the damage to the code to implement the above may not be too
bad.  Here is an illustration (not even compile tested) of the idea:

 - Earlier, after reading the config, we asked is_rerere_enabled()
   and let its logic decide if rerere is to be used, giving no
   influence to the incoming "flags" parameter.  Then the value of
   rerere_autoupdate read from the config is further adjusted by the
   value in "flags" parameter that relays --[no-]rerere-autoupdate
   from the command line.

 - Instead, after reading the config, we can tweak it with the
   "flags", and flip rerere_enabled to true if autoupdate is
   enabled, before making a call to is_rerere_enabled().

I do not think we have a test that insists that rerere does not kick
in in a repository where rerere is disabled and the command line
asks for "--rerere-autoupdate", so I suspect that with this patch, I
would not be surprised if no test breaks.  If we think this takes us
in a good direction, we should add a few tests to make sure at least
the following two:

 - In a repository with rerere disabled, running a command with the
   "--rerere-autoupdate" option will enable rerere for that single
   invocation of the command.

 - In a repository with rerere enabled, running a command with the
   "--no-rerere-autoupdate" option does not disable rerere for that
   single invocation of the command.

---

 rerere.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git c/rerere.c w/rerere.c
index 876ab435da..16d3e865e6 100644
--- c/rerere.c
+++ w/rerere.c
@@ -872,11 +872,13 @@ int setup_rerere(struct repository *r, struct string_list *merge_rr, int flags)
 	int fd;
 
 	git_rerere_config();
+	if (flags & (RERERE_AUTOUPDATE|RERERE_NOAUTOUPDATE))
+		rerere_autoupdate = !!(flags & RERERE_AUTOUPDATE);
+	if (rerere_autoupdate)
+		rerere_enabled = 1;
 	if (!is_rerere_enabled())
 		return -1;
 
-	if (flags & (RERERE_AUTOUPDATE|RERERE_NOAUTOUPDATE))
-		rerere_autoupdate = !!(flags & RERERE_AUTOUPDATE);
 	if (flags & RERERE_READONLY)
 		fd = 0;
 	else