]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit.c
Merge branch 'la/trailer-cleanups' into maint-2.43
[thirdparty/git.git] / commit.c
index 4440fbabb83886848efd520f28697059606a7a18..b7dc1854add558e6d916fe15e79d3840269982ba 100644 (file)
--- 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, 0);
+
+               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 :