Skip to content

Commit dea6737

Browse files
committed
Merge branch 'ds/close-object-store' into maint
The commit-graph file is now part of the "files that the runtime may keep open file descriptors on, all of which would need to be closed when done with the object store", and the file descriptor to an existing commit-graph file now is closed before "gc" finalizes a new instance to replace it. * ds/close-object-store: packfile: rename close_all_packs to close_object_store packfile: close commit-graph in close_all_packs commit-graph: use raw_object_store when closing commit-graph: extract write_commit_graph_file() commit-graph: extract copy_oids_to_commits() commit-graph: extract count_distinct_commits() commit-graph: extract fill_oids_from_all_packs() commit-graph: extract fill_oids_from_commit_hex() commit-graph: extract fill_oids_from_packs() commit-graph: create write_commit_graph_context commit-graph: remove Future Work section commit-graph: collapse parameters into flags commit-graph: return with errors during write commit-graph: fix the_repository reference
2 parents 689204c + 2d511cf commit dea6737

19 files changed

+398
-327
lines changed

Documentation/technical/commit-graph.txt

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,6 @@ Design Details
127127
helpful for these clones, anyway. The commit-graph will not be read or
128128
written when shallow commits are present.
129129

130-
Future Work
131-
-----------
132-
133-
- After computing and storing generation numbers, we must make graph
134-
walks aware of generation numbers to gain the performance benefits they
135-
enable. This will mostly be accomplished by swapping a commit-date-ordered
136-
priority queue with one ordered by generation number. The following
137-
operations are important candidates:
138-
139-
- 'log --topo-order'
140-
- 'tag --merged'
141-
142-
- A server could provide a commit-graph file as part of the network protocol
143-
to avoid extra calculations by clients. This feature is only of benefit if
144-
the user is willing to trust the file, because verifying the file is correct
145-
is as hard as computing it from scratch.
146-
147130
Related Links
148131
-------------
149132
[0] https://bugs.chromium.org/p/git/issues/detail?id=8

builtin/am.c

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

builtin/clone.c

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

12471247
if (option_dissociate) {
1248-
close_all_packs(the_repository->objects);
1248+
close_object_store(the_repository->objects);
12491249
dissociate_from_references();
12501250
}
12511251

builtin/commit-graph.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ static int graph_write(int argc, const char **argv)
141141
struct string_list *pack_indexes = NULL;
142142
struct string_list *commit_hex = NULL;
143143
struct string_list lines;
144+
int result = 0;
145+
unsigned int flags = COMMIT_GRAPH_PROGRESS;
144146

145147
static struct option builtin_commit_graph_write_options[] = {
146148
OPT_STRING(0, "object-dir", &opts.obj_dir,
@@ -165,13 +167,13 @@ static int graph_write(int argc, const char **argv)
165167
die(_("use at most one of --reachable, --stdin-commits, or --stdin-packs"));
166168
if (!opts.obj_dir)
167169
opts.obj_dir = get_object_directory();
170+
if (opts.append)
171+
flags |= COMMIT_GRAPH_APPEND;
168172

169173
read_replace_refs = 0;
170174

171-
if (opts.reachable) {
172-
write_commit_graph_reachable(opts.obj_dir, opts.append, 1);
173-
return 0;
174-
}
175+
if (opts.reachable)
176+
return write_commit_graph_reachable(opts.obj_dir, flags);
175177

176178
string_list_init(&lines, 0);
177179
if (opts.stdin_packs || opts.stdin_commits) {
@@ -188,14 +190,14 @@ static int graph_write(int argc, const char **argv)
188190
UNLEAK(buf);
189191
}
190192

191-
write_commit_graph(opts.obj_dir,
192-
pack_indexes,
193-
commit_hex,
194-
opts.append,
195-
1);
193+
if (write_commit_graph(opts.obj_dir,
194+
pack_indexes,
195+
commit_hex,
196+
flags))
197+
result = 1;
196198

197199
UNLEAK(lines);
198-
return 0;
200+
return result;
199201
}
200202

201203
int cmd_commit_graph(int argc, const char **argv, const char *prefix)

builtin/commit.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,8 +1669,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
16691669
"new_index file. Check that disk is not full and quota is\n"
16701670
"not exceeded, and then \"git reset HEAD\" to recover."));
16711671

1672-
if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0))
1673-
write_commit_graph_reachable(get_object_directory(), 0, 0);
1672+
if (git_env_bool(GIT_TEST_COMMIT_GRAPH, 0) &&
1673+
write_commit_graph_reachable(get_object_directory(), 0))
1674+
return 1;
16741675

16751676
repo_rerere(the_repository, 0);
16761677
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);

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: 6 additions & 5 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,13 +681,14 @@ 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

688-
if (gc_write_commit_graph)
689-
write_commit_graph_reachable(get_object_directory(), 0,
690-
!quiet && !daemonized);
688+
if (gc_write_commit_graph &&
689+
write_commit_graph_reachable(get_object_directory(),
690+
!quiet && !daemonized ? COMMIT_GRAPH_PROGRESS : 0))
691+
return 1;
691692

692693
if (auto_gc && too_many_loose_objects())
693694
warning(_("There are too many unreachable loose objects; "

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
@@ -742,7 +742,7 @@ static int finish_rebase(struct rebase_options *opts)
742742

743743
delete_ref(NULL, "REBASE_HEAD", NULL, REF_NO_DEREF);
744744
apply_autostash(opts);
745-
close_all_packs(the_repository->objects);
745+
close_object_store(the_repository->objects);
746746
/*
747747
* We ignore errors in 'gc --auto', since the
748748
* 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);

0 commit comments

Comments
 (0)