Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Alex Coppens <alex@nativetouch.com>, git@vger.kernel.org
Subject: [PATCH] rerere: exit silently on "forget" when rerere is disabled
Date: Thu, 14 May 2015 15:20:52 -0400	[thread overview]
Message-ID: <20150514192052.GB9329@peff.net> (raw)
In-Reply-To: <xmqqr3qjj7b6.fsf@gitster.dls.corp.google.com>

On Thu, May 14, 2015 at 12:19:25PM -0700, Junio C Hamano wrote:

> > 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

  reply	other threads:[~2015-05-14 19:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-14 18:05 Problem with rerere forget Alex Coppens
2015-05-14 18:21 ` Stefan Beller
2015-05-14 18:40   ` Alex Coppens
2015-05-14 18:57     ` Stefan Beller
2015-05-14 18:49 ` Junio C Hamano
2015-05-14 19:16   ` Jeff King
2015-05-14 19:19     ` Junio C Hamano
2015-05-14 19:20       ` Jeff King [this message]
2015-05-14 19:33         ` [PATCH] rerere: exit silently on "forget" when rerere is disabled Junio C Hamano
2015-05-14 20:22           ` Jeff King
2015-05-14 20:51             ` Alex Coppens
2015-05-14 20:56               ` Jeff King
2015-05-14 20:59                 ` Alex Coppens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150514192052.GB9329@peff.net \
    --to=peff@peff.net \
    --cc=alex@nativetouch.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox