]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
submodule: make zero-oid comparison hash function agnostic
[thirdparty/git.git] / commit-graph.c
index 0cad55eec2d5603ccd375e093206f0c971c3524a..7f4519ec3b1a6659551fc4ba792cbef151367a4e 100644 (file)
@@ -213,8 +213,9 @@ static int prepare_commit_graph(struct repository *r)
                return !!r->objects->commit_graph;
        r->objects->commit_graph_attempted = 1;
 
-       if (repo_config_get_bool(r, "core.commitgraph", &config_value) ||
-           !config_value)
+       if (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) &&
+           (repo_config_get_bool(r, "core.commitgraph", &config_value) ||
+           !config_value))
                /*
                 * This repository is not configured to use commit graphs, so
                 * do not load one. (But report commit_graph_attempted anyway
@@ -783,7 +784,7 @@ void write_commit_graph(const char *obj_dir,
 
        count_distinct = 1;
        for (i = 1; i < oids.nr; i++) {
-               if (oidcmp(&oids.list[i-1], &oids.list[i]))
+               if (!oideq(&oids.list[i - 1], &oids.list[i]))
                        count_distinct++;
        }
 
@@ -797,7 +798,7 @@ void write_commit_graph(const char *obj_dir,
        num_extra_edges = 0;
        for (i = 0; i < oids.nr; i++) {
                int num_parents = 0;
-               if (i > 0 && !oidcmp(&oids.list[i-1], &oids.list[i]))
+               if (i > 0 && oideq(&oids.list[i - 1], &oids.list[i]))
                        continue;
 
                commits.list[commits.nr] = lookup_commit(the_repository, &oids.list[i]);
@@ -918,7 +919,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
        f = hashfd(devnull, NULL);
        hashwrite(f, g->data, g->data_len - g->hash_len);
        finalize_hashfile(f, checksum.hash, CSUM_CLOSE);
-       if (hashcmp(checksum.hash, g->data + g->data_len - g->hash_len)) {
+       if (!hasheq(checksum.hash, g->data + g->data_len - g->hash_len)) {
                graph_report(_("the commit-graph file has incorrect checksum and is likely corrupt"));
                verify_commit_graph_error = VERIFY_COMMIT_GRAPH_ERROR_HASH;
        }
@@ -978,7 +979,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
                        continue;
                }
 
-               if (oidcmp(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid,
+               if (!oideq(&get_commit_tree_in_graph_one(g, graph_commit)->object.oid,
                           get_commit_tree_oid(odb_commit)))
                        graph_report("root tree OID for commit %s in commit-graph is %s != %s",
                                     oid_to_hex(&cur_oid),
@@ -995,7 +996,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g)
                                break;
                        }
 
-                       if (oidcmp(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
+                       if (!oideq(&graph_parents->item->object.oid, &odb_parents->item->object.oid))
                                graph_report("commit-graph parent for %s is %s != %s",
                                             oid_to_hex(&cur_oid),
                                             oid_to_hex(&graph_parents->item->object.oid),