fsck_handle_reflog_sha1(): new function

New function, extracted from fsck_handle_reflog_ent(). The extra
is_null_sha1() test for the new reference is currently unnecessary, as
reflogs are deleted when the reference itself is deleted. But it
doesn't hurt, either.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael Haggerty 2015-06-08 15:40:04 +02:00 committed by Junio C Hamano
parent 3d4a3ffe64
commit d66ae59b8a

View file

@ -451,28 +451,29 @@ static void fsck_dir(int i, char *path)
static int default_refs; static int default_refs;
static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, static void fsck_handle_reflog_sha1(unsigned char *sha1)
const char *email, unsigned long timestamp, int tz,
const char *message, void *cb_data)
{ {
struct object *obj; struct object *obj;
if (verbose) if (!is_null_sha1(sha1)) {
fprintf(stderr, "Checking reflog %s->%s\n", obj = lookup_object(sha1);
sha1_to_hex(osha1), sha1_to_hex(nsha1));
if (!is_null_sha1(osha1)) {
obj = lookup_object(osha1);
if (obj) { if (obj) {
obj->used = 1; obj->used = 1;
mark_object_reachable(obj); mark_object_reachable(obj);
} }
} }
obj = lookup_object(nsha1); }
if (obj) {
obj->used = 1; static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
mark_object_reachable(obj); const char *email, unsigned long timestamp, int tz,
} const char *message, void *cb_data)
{
if (verbose)
fprintf(stderr, "Checking reflog %s->%s\n",
sha1_to_hex(osha1), sha1_to_hex(nsha1));
fsck_handle_reflog_sha1(osha1);
fsck_handle_reflog_sha1(nsha1);
return 0; return 0;
} }