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

[PATCH] rerere: exit silently on "forget" when rerere is disabled

From
Jeff King <peff@peff.net>
Date
May 14, 2015, 19:20 UTC
Message-ID
<20150514192052.GB9329@peff.net>
In-Reply-To
<xmqqr3qjj7b6.fsf@gitster.dls.corp.google.com>
On Thu, May 14, 2015 at 12:19:25PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> > It looks like we need to pay more attention to the return value of
> > setup_rerere, which is what is supposed to take the lock.
> 
> Good spotting.  The normal rerere does check, but rerere-forget
> codepath seems to forget it.
Here's a patch.
-- >8 --
Subject: rerere: exit silently on "forget" when rerere is disabled

If you run "git rerere forget foo" in a repository that does not have rerere enabled, git hits an internal error:

  $ git init -q
  $ git rerere forget foo
  fatal: BUG: attempt to commit unlocked object

The problem is that setup_rerere() will not actually take the lock if the rerere system is disabled. We should notice this and return early. We can return with a success code here, because we know there is nothing to forget.

Signed-off-by: Jeff King <peff@peff.net>
---
 rerere.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/rerere.c b/rerere.c
index 31644de..94aea9a 100644
--- a/rerere.c
+++ b/rerere.c
@@ -659,6 +659,8 @@ int rerere_forget(struct pathspec *pathspec)
 		return error("Could not read index");
 
 	fd = setup_rerere(&merge_rr, RERERE_NOAUTOUPDATE);
+	if (fd < 0)
+		return 0;
 
 	unmerge_cache(pathspec);
 	find_conflict(&conflict);
-- 
2.4.1.396.g7ba6d7b
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 13 in “Problem with rerere forget”
  1. Alex CoppensMay 14, 2015
  2. Stefan BellerMay 14, 2015
  3. Alex CoppensMay 14, 2015
  4. Stefan BellerMay 14, 2015
  5. Junio C HamanoMay 14, 2015
  6. Jeff KingMay 14, 2015
  7. Junio C HamanoMay 14, 2015
  8. rerere: exit silently on "forget" when rerere is disabledJeff King, May 14, 2015
  9. Junio C HamanoMay 14, 2015
  10. Jeff KingMay 14, 2015
  11. Alex CoppensMay 14, 2015
  12. Jeff KingMay 14, 2015
  13. Alex CoppensMay 14, 2015

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.