Skip to content

Commit f5d2f34

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge branch 'close-graph-everywhere'
This topic branch is a backport of gitgitgadget#208, which avoids a lock contention in `git gc --auto` where the `git gc` process holds a read lock to the `commit-graph` file (if `core.commitgraph=true`) and the spawned `git commit-graph write` (if `gc.writecommitgraph=true`) tries to overwrite it. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2 parents eec9ec1 + ecd34f4 commit f5d2f34

File tree

14 files changed

+21
-18
lines changed

14 files changed

+21
-18
lines changed

builtin/am.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1803,7 +1803,7 @@ static void am_run(struct am_state *state, int resume)
18031803
*/
18041804
if (!state->rebasing) {
18051805
am_destroy(state);
1806-
close_all_packs(the_repository->objects);
1806+
close_object_store(the_repository->objects);
18071807
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
18081808
}
18091809
}

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12471247
transport_disconnect(transport);
12481248

12491249
if (option_dissociate) {
1250-
close_all_packs(the_repository->objects);
1250+
close_object_store(the_repository->objects);
12511251
dissociate_from_references();
12521252
}
12531253

builtin/fetch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
16721672

16731673
string_list_clear(&list, 0);
16741674

1675-
close_all_packs(the_repository->objects);
1675+
close_object_store(the_repository->objects);
16761676

16771677
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
16781678
if (verbosity < 0)

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
653653
gc_before_repack();
654654

655655
if (!repository_format_precious_objects) {
656-
close_all_packs(the_repository->objects);
656+
close_object_store(the_repository->objects);
657657
if (run_command_v_opt(repack.argv, RUN_GIT_CMD))
658658
die(FAILED_RUN, repack.argv[0]);
659659

@@ -681,7 +681,7 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
681681
report_garbage = report_pack_garbage;
682682
reprepare_packed_git(the_repository);
683683
if (pack_garbage.nr > 0) {
684-
close_all_packs(the_repository->objects);
684+
close_object_store(the_repository->objects);
685685
clean_pack_garbage();
686686
}
687687

builtin/merge.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ static void finish(struct commit *head_commit,
457457
* We ignore errors in 'gc --auto', since the
458458
* user should see them.
459459
*/
460-
close_all_packs(the_repository->objects);
460+
close_object_store(the_repository->objects);
461461
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
462462
}
463463
}

builtin/rebase.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static int finish_rebase(struct rebase_options *opts)
741741

742742
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
743743
apply_autostash(opts);
744-
close_all_packs(the_repository->objects);
744+
close_object_store(the_repository->objects);
745745
/*
746746
* We ignore errors in 'gc --auto', since the
747747
* user should see them.

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2043,7 +2043,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
20432043
proc.git_cmd = 1;
20442044
proc.argv = argv_gc_auto;
20452045

2046-
close_all_packs(the_repository->objects);
2046+
close_object_store(the_repository->objects);
20472047
if (!start_command(&proc)) {
20482048
if (use_sideband)
20492049
copy_to_sideband(proc.err, -1, NULL);

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
422422
if (!names.nr && !po_args.quiet)
423423
printf_ln(_("Nothing new to pack."));
424424

425-
close_all_packs(the_repository->objects);
425+
close_object_store(the_repository->objects);
426426

427427
/*
428428
* Ok we have prepared all new packfiles.

commit-graph.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,10 @@ int generation_numbers_enabled(struct repository *r)
361361
return !!first_generation;
362362
}
363363

364-
void close_commit_graph(struct repository *r)
364+
void close_commit_graph(struct raw_object_store *o)
365365
{
366-
free_commit_graph(r->objects->commit_graph);
367-
r->objects->commit_graph = NULL;
366+
free_commit_graph(o->commit_graph);
367+
o->commit_graph = NULL;
368368
}
369369

370370
static int bsearch_graph(struct commit_graph *g, struct object_id *oid, uint32_t *pos)
@@ -1110,7 +1110,7 @@ void write_commit_graph(const char *obj_dir,
11101110
stop_progress(&progress);
11111111
strbuf_release(&progress_title);
11121112

1113-
close_commit_graph(the_repository);
1113+
close_commit_graph(the_repository->objects);
11141114
finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
11151115
commit_lock_file(&lk);
11161116

commit-graph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void write_commit_graph(const char *obj_dir,
7474

7575
int verify_commit_graph(struct repository *r, struct commit_graph *g);
7676

77-
void close_commit_graph(struct repository *);
77+
void close_commit_graph(struct raw_object_store *);
7878
void free_commit_graph(struct commit_graph *);
7979

8080
#endif

0 commit comments

Comments
 (0)