rerere: exit silently on "forget" when rerere is disabled
authorJeff King <peff@peff.net>
Thu, 14 May 2015 19:20:52 +0000 (15:20 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 May 2015 19:33:15 +0000 (12:33 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rerere.c
index d55aa8a01b4a4f200f24972795f2887644a06d43..fd65a93873625d96c9824183cd81be1b408a8952 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -667,6 +667,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);