fsck_handle_reflog_sha1(): new function
[gitweb.git] / builtin / fsck.c
index a27515aeaa2debabdb14a03d271fe423d13b19d2..295d3b9e9ed7c659a685f3db37e39a6a81fadeaa 100644 (file)
@@ -451,28 +451,29 @@ static void fsck_dir(int i, char *path)
 
 static int default_refs;
 
-static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
-               const char *email, unsigned long timestamp, int tz,
-               const char *message, void *cb_data)
+static void fsck_handle_reflog_sha1(unsigned char *sha1)
 {
        struct object *obj;
 
-       if (verbose)
-               fprintf(stderr, "Checking reflog %s->%s\n",
-                       sha1_to_hex(osha1), sha1_to_hex(nsha1));
-
-       if (!is_null_sha1(osha1)) {
-               obj = lookup_object(osha1);
+       if (!is_null_sha1(sha1)) {
+               obj = lookup_object(sha1);
                if (obj) {
                        obj->used = 1;
                        mark_object_reachable(obj);
                }
        }
-       obj = lookup_object(nsha1);
-       if (obj) {
-               obj->used = 1;
-               mark_object_reachable(obj);
-       }
+}
+
+static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
+               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;
 }
 
@@ -600,7 +601,7 @@ static int fsck_cache_tree(struct cache_tree *it)
 }
 
 static char const * const fsck_usage[] = {
-       N_("git fsck [options] [<object>...]"),
+       N_("git fsck [<options>] [<object>...]"),
        NULL
 };