]> asedeno.scripts.mit.edu Git - git.git/blobdiff - builtin-fsck.c
Improve use of lockfile API
[git.git] / builtin-fsck.c
index 64da3bd363dbbbd5ac9cbff93285f98cc9362898..2a6e94deaf6b27f27ad7655ebf6072a05b25017c 100644 (file)
@@ -555,20 +555,23 @@ static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, in
        return 0;
 }
 
+static int is_branch(const char *refname)
+{
+       return !strcmp(refname, "HEAD") || !prefixcmp(refname, "refs/heads/");
+}
+
 static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data)
 {
        struct object *obj;
 
-       obj = lookup_object(sha1);
+       obj = parse_object(sha1);
        if (!obj) {
-               if (has_sha1_file(sha1)) {
-                       default_refs++;
-                       return 0; /* it is in a pack */
-               }
                error("%s: invalid sha1 pointer %s", refname, sha1_to_hex(sha1));
                /* We'll continue with the rest despite the error.. */
                return 0;
        }
+       if (obj->type != OBJ_COMMIT && is_branch(refname))
+               error("%s: not a commit", refname);
        default_refs++;
        obj->used = 1;
        mark_reachable(obj, REACHABLE);
@@ -680,7 +683,7 @@ static struct option fsck_opts[] = {
        OPT_BOOLEAN(0, "cache", &keep_cache_objects, "make index objects head nodes"),
        OPT_BOOLEAN(0, "reflogs", &include_reflogs, "make reflogs head nodes (default)"),
        OPT_BOOLEAN(0, "full", &check_full, "also consider alternate objects"),
-       OPT_BOOLEAN(0, "struct", &check_strict, "enable more strict checking"),
+       OPT_BOOLEAN(0, "strict", &check_strict, "enable more strict checking"),
        OPT_BOOLEAN(0, "lost-found", &write_lost_and_found,
                                "write dangling objects in .git/lost-found"),
        OPT_END(),