Skip to content

Commit baf16c8

Browse files
Merge pull request git-for-windows#168: commit: remove parse_commit_no_graph()
The parse_commit_no_graph() method was added in 43d3561 ("commit-graph write: don't die if the existing graph is corrupt" 2019-03-25) as a way to avoid persisting bad data across commit-graph files. That is, if the commit-graph file has undetected corrupt data -- such as a flipped bit in a parent int-id value -- then that data will persist to the next commit-graph file. The parse_commit_no_graph() method was used to always use the pack data directly instead. Unfortunately, this comes at a significant performance cost. In both time and memory, parsing from pack files is much slower than parsing from the commit-graph file. In a repository with 4.5 million commits, this can lead to Git taking up to 11gb of memory to rewrite the file. Now that the incremental commit-graph file format exists, we can rely on the quality of the commit-graph file if we follow the two-step pattern of (1) write a commit-graph with "--split" and (2) run "git commit-graph verify --shallow" to verify the tip file.
2 parents 7c49a1f + a405834 commit baf16c8

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

commit-graph.c

+3-7
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,6 @@ static int prepare_commit_graph(struct repository *r)
468468
struct object_directory *odb;
469469
int config_value;
470470

471-
if (git_env_bool(GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD, 0))
472-
die("dying as requested by the '%s' variable on commit-graph load!",
473-
GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD);
474-
475471
if (r->objects->commit_graph_attempted)
476472
return !!r->objects->commit_graph;
477473
r->objects->commit_graph_attempted = 1;
@@ -841,7 +837,7 @@ static void write_graph_chunk_data(struct hashfile *f, int hash_len,
841837
uint32_t packedDate[2];
842838
display_progress(ctx->progress, ++ctx->progress_cnt);
843839

844-
parse_commit_no_graph(*list);
840+
parse_commit(*list);
845841
hashwrite(f, get_commit_tree_oid(*list)->hash, hash_len);
846842

847843
parent = (*list)->parents;
@@ -1059,7 +1055,7 @@ static void close_reachable(struct write_commit_graph_context *ctx)
10591055
if (!parse_commit(commit) &&
10601056
commit->graph_pos == COMMIT_NOT_FROM_GRAPH)
10611057
add_missing_parents(ctx, commit);
1062-
} else if (!parse_commit_no_graph(commit))
1058+
} else if (!parse_commit(commit))
10631059
add_missing_parents(ctx, commit);
10641060
}
10651061
stop_progress(&ctx->progress);
@@ -1295,7 +1291,7 @@ static void copy_oids_to_commits(struct write_commit_graph_context *ctx)
12951291
ctx->commits.list[ctx->commits.nr]->graph_pos != COMMIT_NOT_FROM_GRAPH)
12961292
continue;
12971293

1298-
parse_commit_no_graph(ctx->commits.list[ctx->commits.nr]);
1294+
parse_commit(ctx->commits.list[ctx->commits.nr]);
12991295

13001296
for (parent = ctx->commits.list[ctx->commits.nr]->parents;
13011297
parent; parent = parent->next)

commit-graph.h

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "cache.h"
88

99
#define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH"
10-
#define GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD "GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD"
1110

1211
struct commit;
1312

commit.h

-6
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ static inline int repo_parse_commit(struct repository *r, struct commit *item)
8989
{
9090
return repo_parse_commit_gently(r, item, 0);
9191
}
92-
93-
static inline int parse_commit_no_graph(struct commit *commit)
94-
{
95-
return repo_parse_commit_internal(the_repository, commit, 0, 0);
96-
}
97-
9892
#ifndef NO_THE_REPOSITORY_COMPATIBILITY_MACROS
9993
#define parse_commit_internal(item, quiet, use) repo_parse_commit_internal(the_repository, item, quiet, use)
10094
#define parse_commit_gently(item, quiet) repo_parse_commit_gently(the_repository, item, quiet)

t/t5318-commit-graph.sh

+3-9
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,7 @@ corrupt_graph_verify() {
385385
test_must_fail git commit-graph verify 2>test_err &&
386386
grep -v "^+" test_err >err &&
387387
test_i18ngrep "$grepstr" err &&
388-
if test "$2" != "no-copy"
389-
then
390-
cp $objdir/info/commit-graph commit-graph-pre-write-test
391-
fi &&
392-
git status --short &&
393-
GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD=true git commit-graph write &&
394-
git commit-graph verify
388+
git status --short
395389
}
396390

397391
# usage: corrupt_graph_and_verify <position> <data> <string> [<zero_pos>]
@@ -415,9 +409,10 @@ corrupt_graph_and_verify() {
415409
}
416410

417411
test_expect_success POSIXPERM,SANITY 'detect permission problem' '
412+
test_when_finished chmod 666 $objdir/info/commit-graph &&
418413
corrupt_graph_setup &&
419414
chmod 000 $objdir/info/commit-graph &&
420-
corrupt_graph_verify "Could not open" "no-copy"
415+
corrupt_graph_verify "Could not open"
421416
'
422417

423418
test_expect_success 'detect too small' '
@@ -536,7 +531,6 @@ test_expect_success 'git fsck (checks commit-graph)' '
536531
git fsck &&
537532
corrupt_graph_and_verify $GRAPH_BYTE_FOOTER "\00" \
538533
"incorrect checksum" &&
539-
cp commit-graph-pre-write-test $objdir/info/commit-graph &&
540534
test_must_fail git fsck
541535
'
542536

0 commit comments

Comments
 (0)