for_each_reflog(): don't abort for bad references
authorMichael Haggerty <mhagger@alum.mit.edu>
Sat, 18 Jun 2016 04:15:17 +0000 (06:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 20 Jun 2016 18:38:20 +0000 (11:38 -0700)
If there is a file under "$GIT_DIR/logs" with no corresponding
reference, the old code was emitting an error message, aborting the
reflog iteration, and returning -1. But

* None of the callers was checking the exit value

* The callers all want to find all legitimate reflogs (sometimes for the
purpose of determining object reachability!) and wouldn't benefit from
a truncated iteration anyway.

So instead, emit an error message and skip the "broken" reflog, but
continue with the iteration.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c
index 4232da8cb7184ff0c501efdce3c64e9e091c2ad8..ab40db332630057bde5f85b7718349aa9db99f11 100644 (file)
@@ -3324,7 +3324,7 @@ static int do_for_each_reflog(struct strbuf *name, each_ref_fn fn, void *cb_data
                                struct object_id oid;
 
                                if (read_ref_full(name->buf, 0, oid.hash, NULL))
-                                       retval = error("bad ref for %s", name->buf);
+                                       error("bad ref for %s", name->buf);
                                else
                                        retval = fn(name->buf, &oid, 0, cb_data);
                        }