diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2015-06-08 15:40:05 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-06-08 12:40:36 -0700 |
commit | 19bf6c9b345d18150805bde328284692d9fb3a91 (patch) | |
tree | c63ad93cef28a64a377a51880ae06f8696998cd6 /builtin | |
parent | d66ae59b8a76c18da2900482c47d4177a1271eb9 (diff) | |
download | git-19bf6c9b345d18150805bde328284692d9fb3a91.tar.gz |
fsck: report errors if reflog entries point at invalid objectsmh/fsck-reflog-entries
Previously, if a reflog entry's old or new SHA-1 was not resolvable to
an object, that SHA-1 was silently ignored. Instead, report such cases
as errors.
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/fsck.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/builtin/fsck.c b/builtin/fsck.c index 295d3b9e9e..6b6f31997c 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -451,7 +451,7 @@ static void fsck_dir(int i, char *path) static int default_refs; -static void fsck_handle_reflog_sha1(unsigned char *sha1) +static void fsck_handle_reflog_sha1(const char *refname, unsigned char *sha1) { struct object *obj; @@ -460,6 +460,9 @@ static void fsck_handle_reflog_sha1(unsigned char *sha1) if (obj) { obj->used = 1; mark_object_reachable(obj); + } else { + error("%s: invalid reflog entry %s", refname, sha1_to_hex(sha1)); + errors_found |= ERROR_REACHABLE; } } } @@ -468,18 +471,20 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, const char *email, unsigned long timestamp, int tz, const char *message, void *cb_data) { + const char *refname = cb_data; + if (verbose) fprintf(stderr, "Checking reflog %s->%s\n", sha1_to_hex(osha1), sha1_to_hex(nsha1)); - fsck_handle_reflog_sha1(osha1); - fsck_handle_reflog_sha1(nsha1); + fsck_handle_reflog_sha1(refname, osha1); + fsck_handle_reflog_sha1(refname, nsha1); return 0; } static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data) { - for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL); + for_each_reflog_ent(logname, fsck_handle_reflog_ent, (void *)logname); return 0; } |