Skip to content

Commit d66ae59

Browse files
mhaggergitster
authored andcommitted
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>
1 parent 3d4a3ff commit d66ae59

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

builtin/fsck.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -451,28 +451,29 @@ static void fsck_dir(int i, char *path)
451451

452452
static int default_refs;
453453

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)
457455
{
458456
struct object *obj;
459457

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);
466460
if (obj) {
467461
obj->used = 1;
468462
mark_object_reachable(obj);
469463
}
470464
}
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);
476477
return 0;
477478
}
478479

0 commit comments

Comments
 (0)