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>

Michael Haggerty committed Jun 8, 2015 at 15:40 UTC d66ae59b8a76c18da2900482c47d4177a1271eb9
1 file changed +15 -14
builtin/fsck.c
+15 -14
@@ -451,28 +451,29 @@ static void fsck_dir(int i, char *path)
451
452 static int default_refs;
453
454 -static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
455 - const char *email, unsigned long timestamp, int tz,
456 - const char *message, void *cb_data)
454 +static void fsck_handle_reflog_sha1(unsigned char *sha1)
455 {
456 struct object *obj;
457
460 - if (verbose)
461 - fprintf(stderr, "Checking reflog %s->%s\n",
462 - sha1_to_hex(osha1), sha1_to_hex(nsha1));
463 -
464 - if (!is_null_sha1(osha1)) {
465 - obj = lookup_object(osha1);
458 + if (!is_null_sha1(sha1)) {
459 + obj = lookup_object(sha1);
460 if (obj) {
461 obj->used = 1;
462 mark_object_reachable(obj);
463 }
464 }
471 - obj = lookup_object(nsha1);
472 - if (obj) {
473 - obj->used = 1;
474 - mark_object_reachable(obj);
475 - }
465 +}
466 +
467 +static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
468 + const char *email, unsigned long timestamp, int tz,
469 + const char *message, void *cb_data)
470 +{
471 + if (verbose)
472 + fprintf(stderr, "Checking reflog %s->%s\n",
473 + sha1_to_hex(osha1), sha1_to_hex(nsha1));
474 +
475 + fsck_handle_reflog_sha1(osha1);
476 + fsck_handle_reflog_sha1(nsha1);
477 return 0;
478 }
479