Skip to content

Commit ec65231

Browse files
peffgitster
authored andcommitted
fsck: stop checking commit->parent counts
In 4516338 (builtin-fsck: reports missing parent commits, 2008-02-25), we added code to check that fsck found the same number of parents from parsing the commit itself as we see in the commit struct we got from parse_commit_buffer(). Back then the rationale was that the normal commit parser might skip some bad parents. But earlier in this series, we started treating that reliably as a parsing error, meaning that we'd complain about it before we even hit the code in fsck.c. Let's drop this code, which now makes fsck_commit_buffer() completely independent of any parsed values in the commit struct (that's conceptually cleaner, and also opens up more refactoring options). Note that we can also drop the MISSING_PARENT and MISSING_GRAFT fsck identifiers. This is no loss, as these would not trigger reliably anyway. We'd hit them only when lookup_commit() failed, which occurs only if we happen to have seen the object with another type already in the same process. In most cases, we'd actually run into the problem during the connectivity walk, not here. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1de6007 commit ec65231

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

fsck.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ static struct oidset gitmodules_done = OIDSET_INIT;
4343
FUNC(MISSING_AUTHOR, ERROR) \
4444
FUNC(MISSING_COMMITTER, ERROR) \
4545
FUNC(MISSING_EMAIL, ERROR) \
46-
FUNC(MISSING_GRAFT, ERROR) \
4746
FUNC(MISSING_NAME_BEFORE_EMAIL, ERROR) \
4847
FUNC(MISSING_OBJECT, ERROR) \
49-
FUNC(MISSING_PARENT, ERROR) \
5048
FUNC(MISSING_SPACE_BEFORE_DATE, ERROR) \
5149
FUNC(MISSING_SPACE_BEFORE_EMAIL, ERROR) \
5250
FUNC(MISSING_TAG, ERROR) \
@@ -739,8 +737,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
739737
unsigned long size, struct fsck_options *options)
740738
{
741739
struct object_id tree_oid, oid;
742-
struct commit_graft *graft;
743-
unsigned parent_count, parent_line_count = 0, author_count;
740+
unsigned author_count;
744741
int err;
745742
const char *buffer_begin = buffer;
746743
const char *p;
@@ -763,24 +760,6 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
763760
return err;
764761
}
765762
buffer = p + 1;
766-
parent_line_count++;
767-
}
768-
graft = lookup_commit_graft(the_repository, &commit->object.oid);
769-
parent_count = commit_list_count(commit->parents);
770-
if (graft) {
771-
if (graft->nr_parent == -1 && !parent_count)
772-
; /* shallow commit */
773-
else if (graft->nr_parent != parent_count) {
774-
err = report(options, &commit->object, FSCK_MSG_MISSING_GRAFT, "graft objects missing");
775-
if (err)
776-
return err;
777-
}
778-
} else {
779-
if (parent_count != parent_line_count) {
780-
err = report(options, &commit->object, FSCK_MSG_MISSING_PARENT, "parent objects missing");
781-
if (err)
782-
return err;
783-
}
784763
}
785764
author_count = 0;
786765
while (skip_prefix(buffer, "author ", &buffer)) {

0 commit comments

Comments
 (0)