Skip to content

Commit 5cb7c73

Browse files
committed
Merge branch 'ds/close-object-store'
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
2 parents e116894 + 2d511cf commit 5cb7c73

14 files changed

+21
-18
lines changed

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
@@ -1252,7 +1252,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12521252
transport_disconnect(transport);
12531253

12541254
if (option_dissociate) {
1255-
close_all_packs(the_repository->objects);
1255+
close_object_store(the_repository->objects);
12561256
dissociate_from_references();
12571257
}
12581258

builtin/fetch.c

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

16811681
string_list_clear(&list, 0);
16821682

1683-
close_all_packs(the_repository->objects);
1683+
close_object_store(the_repository->objects);
16841684

16851685
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
16861686
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
@@ -453,7 +453,7 @@ static void finish(struct commit *head_commit,
453453
* We ignore errors in 'gc --auto', since the
454454
* user should see them.
455455
*/
456-
close_all_packs(the_repository->objects);
456+
close_object_store(the_repository->objects);
457457
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
458458
}
459459
}

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
@@ -2042,7 +2042,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
20422042
proc.git_cmd = 1;
20432043
proc.argv = argv_gc_auto;
20442044

2045-
close_all_packs(the_repository->objects);
2045+
close_object_store(the_repository->objects);
20462046
if (!start_command(&proc)) {
20472047
if (use_sideband)
20482048
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)
@@ -1093,7 +1093,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
10931093
stop_progress(&ctx->progress);
10941094
strbuf_release(&progress_title);
10951095

1096-
close_commit_graph(ctx->r);
1096+
close_commit_graph(ctx->r->objects);
10971097
finalize_hashfile(f, NULL, CSUM_HASH_IN_STREAM | CSUM_FSYNC);
10981098
commit_lock_file(&lk);
10991099

commit-graph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int write_commit_graph(const char *obj_dir,
8282

8383
int verify_commit_graph(struct repository *r, struct commit_graph *g);
8484

85-
void close_commit_graph(struct repository *);
85+
void close_commit_graph(struct raw_object_store *);
8686
void free_commit_graph(struct commit_graph *);
8787

8888
#endif

object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ void raw_object_store_clear(struct raw_object_store *o)
517517
o->loaded_alternates = 0;
518518

519519
INIT_LIST_HEAD(&o->packed_git_mru);
520-
close_all_packs(o);
520+
close_object_store(o);
521521
o->packed_git = NULL;
522522
}
523523

packfile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "tree.h"
1717
#include "object-store.h"
1818
#include "midx.h"
19+
#include "commit-graph.h"
1920

2021
char *odb_pack_name(struct strbuf *buf,
2122
const unsigned char *sha1,
@@ -336,7 +337,7 @@ void close_pack(struct packed_git *p)
336337
close_pack_index(p);
337338
}
338339

339-
void close_all_packs(struct raw_object_store *o)
340+
void close_object_store(struct raw_object_store *o)
340341
{
341342
struct packed_git *p;
342343

@@ -350,6 +351,8 @@ void close_all_packs(struct raw_object_store *o)
350351
close_midx(o->multi_pack_index);
351352
o->multi_pack_index = NULL;
352353
}
354+
355+
close_commit_graph(o);
353356
}
354357

355358
/*

packfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ uint32_t get_pack_fanout(struct packed_git *p, uint32_t value);
9090
unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
9191
void close_pack_windows(struct packed_git *);
9292
void close_pack(struct packed_git *);
93-
void close_all_packs(struct raw_object_store *o);
93+
void close_object_store(struct raw_object_store *o);
9494
void unuse_pack(struct pack_window **);
9595
void clear_delta_base_cache(void);
9696
struct packed_git *add_packed_git(const char *path, size_t path_len, int local);

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ static void deepen_by_rev_list(struct packet_writer *writer, int ac,
722722
{
723723
struct commit_list *result;
724724

725-
close_commit_graph(the_repository);
725+
close_commit_graph(the_repository->objects);
726726
result = get_shallow_commits_by_rev_list(ac, av, SHALLOW, NOT_SHALLOW);
727727
send_shallow(writer, result);
728728
free_commit_list(result);

0 commit comments

Comments
 (0)