Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/fsck.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2019-10-18 07:49:10 +0300
committerJunio C Hamano <gitster@pobox.com>2019-10-28 08:05:17 +0300
commitec65231571d9316144acac9dde49acef279c713c (patch)
tree6a20f4f22a96c9279fc636613ee48ccd30c7fd93 /fsck.c
parent1de6007d851816723e283720ba2683c908d38f10 (diff)
fsck: stop checking commit->parent counts
In 4516338243 (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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'fsck.c')
-rw-r--r--fsck.c23
1 files changed, 1 insertions, 22 deletions
diff --git a/fsck.c b/fsck.c
index 6dfc533fb0..a0f8ae7650 100644
--- a/fsck.c
+++ b/fsck.c
@@ -43,10 +43,8 @@ static struct oidset gitmodules_done = OIDSET_INIT;
FUNC(MISSING_AUTHOR, ERROR) \
FUNC(MISSING_COMMITTER, ERROR) \
FUNC(MISSING_EMAIL, ERROR) \
- FUNC(MISSING_GRAFT, ERROR) \
FUNC(MISSING_NAME_BEFORE_EMAIL, ERROR) \
FUNC(MISSING_OBJECT, ERROR) \
- FUNC(MISSING_PARENT, ERROR) \
FUNC(MISSING_SPACE_BEFORE_DATE, ERROR) \
FUNC(MISSING_SPACE_BEFORE_EMAIL, ERROR) \
FUNC(MISSING_TAG, ERROR) \
@@ -739,8 +737,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
unsigned long size, struct fsck_options *options)
{
struct object_id tree_oid, oid;
- struct commit_graft *graft;
- unsigned parent_count, parent_line_count = 0, author_count;
+ unsigned author_count;
int err;
const char *buffer_begin = buffer;
const char *p;
@@ -763,24 +760,6 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer,
return err;
}
buffer = p + 1;
- parent_line_count++;
- }
- graft = lookup_commit_graft(the_repository, &commit->object.oid);
- parent_count = commit_list_count(commit->parents);
- if (graft) {
- if (graft->nr_parent == -1 && !parent_count)
- ; /* shallow commit */
- else if (graft->nr_parent != parent_count) {
- err = report(options, &commit->object, FSCK_MSG_MISSING_GRAFT, "graft objects missing");
- if (err)
- return err;
- }
- } else {
- if (parent_count != parent_line_count) {
- err = report(options, &commit->object, FSCK_MSG_MISSING_PARENT, "parent objects missing");
- if (err)
- return err;
- }
}
author_count = 0;
while (skip_prefix(buffer, "author ", &buffer)) {