Merge branch 'rs/fsck-null-return-from-lookup'
authorJunio C Hamano <gitster@pobox.com>
Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Oct 2017 05:52:23 +0000 (14:52 +0900)
Improve behaviour of "git fsck" upon finding a missing object.

* rs/fsck-null-return-from-lookup:
fsck: handle NULL return of lookup_blob() and lookup_tree()

1  2 
fsck.c
diff --combined fsck.c
index 2ad00fc4d0356d8ec2cac21d1897a76b5002fd5b,b1579c7e2821a99729af85b1382f7ea5c3824b8f..032699e9ac2622c7d089523a456db0fa83310e14
--- 1/fsck.c
--- 2/fsck.c
+++ b/fsck.c
@@@ -358,15 -358,15 +358,15 @@@ static int fsck_walk_tree(struct tree *
                        continue;
  
                if (S_ISDIR(entry.mode)) {
-                       obj = &lookup_tree(entry.oid)->object;
-                       if (name)
+                       obj = (struct object *)lookup_tree(entry.oid);
+                       if (name && obj)
                                put_object_name(options, obj, "%s%s/", name,
                                        entry.path);
                        result = options->walk(obj, OBJ_TREE, data, options);
                }
                else if (S_ISREG(entry.mode) || S_ISLNK(entry.mode)) {
-                       obj = &lookup_blob(entry.oid)->object;
-                       if (name)
+                       obj = (struct object *)lookup_blob(entry.oid);
+                       if (name && obj)
                                put_object_name(options, obj, "%s%s", name,
                                        entry.path);
                        result = options->walk(obj, OBJ_BLOB, data, options);
@@@ -588,7 -588,6 +588,7 @@@ static int fsck_tree(struct tree *item
                case S_IFREG | 0664:
                        if (!options->strict)
                                break;
 +                      /* fallthrough */
                default:
                        has_bad_modes = 1;
                }
@@@ -737,7 -736,7 +737,7 @@@ static int fsck_commit_buffer(struct co
                buffer += 41;
                parent_line_count++;
        }
 -      graft = lookup_commit_graft(commit->object.oid.hash);
 +      graft = lookup_commit_graft(&commit->object.oid);
        parent_count = commit_list_count(commit->parents);
        if (graft) {
                if (graft->nr_parent == -1 && !parent_count)