summaryrefslogtreecommitdiff
path: root/commit-graph.c
diff options
context:
space:
mode:
authorAlex Henrie <alexhenrie24@gmail.com>2019-10-01 02:29:34 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-02 06:04:16 (GMT)
commit8da02ce62a4e76aea7a02d56b66b10eedc8e6db8 (patch)
tree32eb5f7fe16c8bf5d7effb4e241cb06e36fa97fa /commit-graph.c
parent5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff)
downloadgit-8da02ce62a4e76aea7a02d56b66b10eedc8e6db8.zip
git-8da02ce62a4e76aea7a02d56b66b10eedc8e6db8.tar.gz
git-8da02ce62a4e76aea7a02d56b66b10eedc8e6db8.tar.bz2
commit-graph: remove a duplicate assignment
Leave the variable 'g' uninitialized before it is set just before its first use in front of a loop, which is a much more appropriate place to indicate what it is used for. Also initialize the variable 'num_commits' just before the loop instead of at the beginning of the function for the same reason. Reviewed-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.c')
-rw-r--r--commit-graph.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/commit-graph.c b/commit-graph.c
index fe954ab..9a65ddd 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1519,8 +1519,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
{
- struct commit_graph *g = ctx->r->objects->commit_graph;
- uint32_t num_commits = ctx->commits.nr;
+ struct commit_graph *g;
+ uint32_t num_commits;
uint32_t i;
int max_commits = 0;
@@ -1532,6 +1532,7 @@ static void split_graph_merge_strategy(struct write_commit_graph_context *ctx)
}
g = ctx->r->objects->commit_graph;
+ num_commits = ctx->commits.nr;
ctx->num_commit_graphs_after = ctx->num_commit_graphs_before + 1;
while (g && (g->num_commits <= size_mult * num_commits ||