]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
Merge branch 'ds/commit-graph-genno-fix'
[thirdparty/git.git] / commit-graph.c
index 94d3ab4a04f2ceec5c7d33876e37467f79892033..f70886c2d3d5dce59646253892e0c0adcaf5657c 100644 (file)
@@ -7,7 +7,7 @@
 #include "object.h"
 #include "refs.h"
 #include "revision.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "commit-graph.h"
 #include "object-store.h"
 #include "alloc.h"
@@ -1089,10 +1089,10 @@ static int write_graph_chunk_oids(struct hashfile *f,
        return 0;
 }
 
-static const unsigned char *commit_to_sha1(size_t index, void *table)
+static const struct object_id *commit_to_oid(size_t index, const void *table)
 {
-       struct commit **commits = table;
-       return commits[index]->object.oid.hash;
+       const struct commit * const *commits = table;
+       return &commits[index]->object.oid;
 }
 
 static int write_graph_chunk_data(struct hashfile *f,
@@ -1120,10 +1120,10 @@ static int write_graph_chunk_data(struct hashfile *f,
                if (!parent)
                        edge_value = GRAPH_PARENT_NONE;
                else {
-                       edge_value = sha1_pos(parent->item->object.oid.hash,
-                                             ctx->commits.list,
-                                             ctx->commits.nr,
-                                             commit_to_sha1);
+                       edge_value = oid_pos(&parent->item->object.oid,
+                                            ctx->commits.list,
+                                            ctx->commits.nr,
+                                            commit_to_oid);
 
                        if (edge_value >= 0)
                                edge_value += ctx->new_num_commits_in_base;
@@ -1151,10 +1151,10 @@ static int write_graph_chunk_data(struct hashfile *f,
                else if (parent->next)
                        edge_value = GRAPH_EXTRA_EDGES_NEEDED | num_extra_edges;
                else {
-                       edge_value = sha1_pos(parent->item->object.oid.hash,
-                                             ctx->commits.list,
-                                             ctx->commits.nr,
-                                             commit_to_sha1);
+                       edge_value = oid_pos(&parent->item->object.oid,
+                                            ctx->commits.list,
+                                            ctx->commits.nr,
+                                            commit_to_oid);
 
                        if (edge_value >= 0)
                                edge_value += ctx->new_num_commits_in_base;
@@ -1261,10 +1261,10 @@ static int write_graph_chunk_extra_edges(struct hashfile *f,
 
                /* Since num_parents > 2, this initializer is safe. */
                for (parent = (*list)->parents->next; parent; parent = parent->next) {
-                       int edge_value = sha1_pos(parent->item->object.oid.hash,
-                                                 ctx->commits.list,
-                                                 ctx->commits.nr,
-                                                 commit_to_sha1);
+                       int edge_value = oid_pos(&parent->item->object.oid,
+                                                ctx->commits.list,
+                                                ctx->commits.nr,
+                                                commit_to_oid);
 
                        if (edge_value >= 0)
                                edge_value += ctx->new_num_commits_in_base;
@@ -1643,7 +1643,7 @@ static int add_ref_to_set(const char *refname,
        struct object_id peeled;
        struct refs_cb_data *data = (struct refs_cb_data *)cb_data;
 
-       if (!peel_ref(refname, &peeled))
+       if (!peel_iterated_oid(oid, &peeled))
                oid = &peeled;
        if (oid_object_info(the_repository, oid, NULL) == OBJ_COMMIT)
                oidset_insert(data->commits, oid);
@@ -1879,8 +1879,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
        } else {
                hold_lock_file_for_update_mode(&lk, ctx->graph_name,
                                               LOCK_DIE_ON_ERROR, 0444);
-               fd = lk.tempfile->fd;
-               f = hashfd(lk.tempfile->fd, lk.tempfile->filename.buf);
+               fd = get_lock_file_fd(&lk);
+               f = hashfd(fd, get_lock_file_path(&lk));
        }
 
        chunks[0].id = GRAPH_CHUNKID_OIDFANOUT;
@@ -2033,7 +2033,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
                result = rename(ctx->graph_name, final_graph_name);
 
                for (i = 0; i < ctx->num_commit_graphs_after; i++)
-                       fprintf(lk.tempfile->fp, "%s\n", ctx->commit_graph_hash_after[i]);
+                       fprintf(get_lock_file_fp(&lk), "%s\n", ctx->commit_graph_hash_after[i]);
 
                if (result) {
                        error(_("failed to rename temporary commit-graph file"));