aboutsummaryrefslogtreecommitdiffstats
path: root/commit.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-11-01 12:06:55 +0900
committerJunio C Hamano <gitster@pobox.com>2023-11-01 12:06:55 +0900
commit922cc26e414f91d96f8c6c806c02962edb6158c9 (patch)
tree1b835939e4ad7b8805c1b6142eec8677caac1026 /commit.c
parentThe twenty-first batch (diff)
parentcommit: detect commits that exist in commit-graph but not in the ODB (diff)
downloadgit-922cc26e414f91d96f8c6c806c02962edb6158c9.tar.gz
git-922cc26e414f91d96f8c6c806c02962edb6158c9.zip
Merge branch 'ps/do-not-trust-commit-graph-blindly-for-existence' into kn/rev-list-missing-fix
* ps/do-not-trust-commit-graph-blindly-for-existence: commit: detect commits that exist in commit-graph but not in the ODB commit-graph: introduce envvar to disable commit existence checks
Diffstat (limited to 'commit.c')
-rw-r--r--commit.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/commit.c b/commit.c
index b3223478bc..8405d7c3fc 100644
--- a/commit.c
+++ b/commit.c
@@ -28,6 +28,7 @@
#include "shallow.h"
#include "tree.h"
#include "hook.h"
+#include "parse.h"
static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
@@ -572,8 +573,21 @@ int repo_parse_commit_internal(struct repository *r,
return -1;
if (item->object.parsed)
return 0;
- if (use_commit_graph && parse_commit_in_graph(r, item))
+ if (use_commit_graph && parse_commit_in_graph(r, item)) {
+ static int commit_graph_paranoia = -1;
+
+ if (commit_graph_paranoia == -1)
+ commit_graph_paranoia = git_env_bool(GIT_COMMIT_GRAPH_PARANOIA, 1);
+
+ if (commit_graph_paranoia && !has_object(r, &item->object.oid, 0)) {
+ unparse_commit(r, &item->object.oid);
+ return quiet_on_missing ? -1 :
+ error(_("commit %s exists in commit-graph but not in the object database"),
+ oid_to_hex(&item->object.oid));
+ }
+
return 0;
+ }
if (oid_object_info_extended(r, &item->object.oid, &oi, flags) < 0)
return quiet_on_missing ? -1 :