fsck.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fsck.c b/fsck.c index 05315451c56f..722b65371d38 100644 --- a/fsck.c +++ b/fsck.c @@ -60,6 +60,7 @@ FUNC(NULL_SHA1, WARN) \ FUNC(ZERO_PADDED_FILEMODE, WARN) \ FUNC(NUL_IN_COMMIT, WARN) \ + FUNC(DATE_ORDERING, WARN) \ /* infos (reported as warnings, but ignored by default) */ \ FUNC(BAD_TAG_NAME, INFO) \ FUNC(MISSING_TAGGER_ENTRY, INFO) @@ -604,6 +605,17 @@ static int fsck_ident(const char **ident, struct object *obj, struct fsck_option return 0; } +static void fsck_commit_date(struct fsck_options *options, struct commit *commit) +{ + struct commit_list *p; + + for (p = commit->parents; p; p = p->next) { + struct commit *parent = p->item; + if (commit->date < parent->date) + report(options, &commit->object, FSCK_MSG_DATE_ORDERING, "Bad commit date ordering with parent"); + } +} + static int fsck_commit_buffer(struct commit *commit, const char *buffer, unsigned long size, struct fsck_options *options) { @@ -650,6 +662,7 @@ static int fsck_commit_buffer(struct commit *commit, const char *buffer, return err; } } + fsck_commit_date(options, commit); author_count = 0; while (skip_prefix(buffer, "author ", &buffer)) { author_count++;