]> git.ipfire.org Git - thirdparty/git.git/blobdiff - commit-graph.c
t3429: remove SHA1 annotation
[thirdparty/git.git] / commit-graph.c
index 821900675b27f20f7a1480328f46c53fed97957c..9b02d2c42657b4cef247fee6aa4240dead0ae776 100644 (file)
@@ -434,6 +434,7 @@ static struct commit_graph *load_commit_graph_chain(struct repository *r, const
 
        free(oids);
        fclose(fp);
+       strbuf_release(&line);
 
        return graph_chain;
 }
@@ -466,7 +467,6 @@ static void prepare_commit_graph_one(struct repository *r, const char *obj_dir)
 static int prepare_commit_graph(struct repository *r)
 {
        struct object_directory *odb;
-       int config_value;
 
        if (git_env_bool(GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD, 0))
                die("dying as requested by the '%s' variable on commit-graph load!",
@@ -476,9 +476,10 @@ static int prepare_commit_graph(struct repository *r)
                return !!r->objects->commit_graph;
        r->objects->commit_graph_attempted = 1;
 
+       prepare_repo_settings(r);
+
        if (!git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) &&
-           (repo_config_get_bool(r, "core.commitgraph", &config_value) ||
-           !config_value))
+           r->settings.core_commit_graph != 1)
                /*
                 * This repository is not configured to use commit graphs, so
                 * do not load one. (But report commit_graph_attempted anyway
@@ -1188,7 +1189,7 @@ static int fill_oids_from_packs(struct write_commit_graph_context *ctx,
        }
 
        stop_progress(&ctx->progress);
-       strbuf_reset(&progress_title);
+       strbuf_release(&progress_title);
        strbuf_release(&packname);
 
        return 0;
@@ -1639,7 +1640,7 @@ static void sort_and_scan_merged_commits(struct write_commit_graph_context *ctx)
                                num_parents++;
 
                        if (num_parents > 2)
-                               ctx->num_extra_edges += num_parents - 2;
+                               ctx->num_extra_edges += num_parents - 1;
                }
        }
 
@@ -1716,10 +1717,8 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
        strbuf_addstr(&path, "/info/commit-graphs");
        dir = opendir(path.buf);
 
-       if (!dir) {
-               strbuf_release(&path);
-               return;
-       }
+       if (!dir)
+               goto out;
 
        strbuf_addch(&path, '/');
        dirnamelen = path.len;
@@ -1748,6 +1747,9 @@ static void expire_commit_graphs(struct write_commit_graph_context *ctx)
                if (!found)
                        unlink(path.buf);
        }
+
+out:
+       strbuf_release(&path);
 }
 
 int write_commit_graph(const char *obj_dir,