Skip to content

Commit fc7d1b4

Browse files
committed
Merge branch 'ps/object-source-management' into seen
Code refactoring around object database sources. Comments? * ps/object-source-management: odb: handle recreation of quarantine directories odb: handle changing a repository's commondir chdir-notify: add function to unregister listeners odb: handle initialization of sources in `odb_new()` http-push: stop setting up `the_repository` for each reference t/helper: stop setting up `the_repository` repeatedly builtin/index-pack: fix deferred fsck outside repos oidset: introduce `oidset_equal()` odb: move logic to disable ref updates into repo odb: refactor `odb_clear()` to `odb_free()` odb: adopt logic to close object databases setup: convert `set_git_dir()` to have file scope path: move `enter_repo()` into "setup.c"
2 parents dec8068 + c0b4e42 commit fc7d1b4

31 files changed

+414
-279
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ int cmd_clone(int argc,
16171617
transport_disconnect(transport);
16181618

16191619
if (option_dissociate) {
1620-
close_object_store(the_repository->objects);
1620+
odb_close(the_repository->objects);
16211621
dissociate_from_references();
16221622
}
16231623

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ int cmd_gc(int argc,
10631063
report_garbage = report_pack_garbage;
10641064
odb_reprepare(the_repository->objects);
10651065
if (pack_garbage.nr > 0) {
1066-
close_object_store(the_repository->objects);
1066+
odb_close(the_repository->objects);
10671067
clean_pack_garbage();
10681068
}
10691069

builtin/index-pack.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
16401640
rename_tmp_packfile(&final_index_name, curr_index_name, &index_name,
16411641
hash, "idx", 1);
16421642

1643-
if (do_fsck_object)
1643+
if (do_fsck_object && startup_info->have_repository)
16441644
packfile_store_load_pack(the_repository->objects->packfiles,
16451645
final_index_name, 0);
16461646

@@ -2110,8 +2110,23 @@ int cmd_index_pack(int argc,
21102110
else
21112111
close(input_fd);
21122112

2113-
if (do_fsck_object && fsck_finish(&fsck_options))
2114-
die(_("fsck error in pack objects"));
2113+
if (do_fsck_object) {
2114+
/*
2115+
* We cannot perform queued consistency checks when running
2116+
* outside of a repository because those require us to read
2117+
* from the object database, which is uninitialized.
2118+
*
2119+
* TODO: we may eventually set up an in-memory object database,
2120+
* which would allow us to perform these queued checks.
2121+
*/
2122+
if (!startup_info->have_repository &&
2123+
fsck_has_queued_checks(&fsck_options))
2124+
die(_("cannot perform queued object checks outside "
2125+
"of a repository"));
2126+
2127+
if (fsck_finish(&fsck_options))
2128+
die(_("fsck error in pack objects"));
2129+
}
21152130

21162131
free(opts.anomaly);
21172132
free(objects);

builtin/receive-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@
3434
#include "object-file.h"
3535
#include "object-name.h"
3636
#include "odb.h"
37-
#include "path.h"
3837
#include "protocol.h"
3938
#include "commit-reach.h"
4039
#include "server-info.h"
4140
#include "trace.h"
4241
#include "trace2.h"
4342
#include "worktree.h"
4443
#include "shallow.h"
44+
#include "setup.h"
4545
#include "parse-options.h"
4646

4747
static const char * const receive_pack_usage[] = {

builtin/repack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int cmd_repack(int argc,
488488

489489
string_list_sort(&names);
490490

491-
close_object_store(repo->objects);
491+
odb_close(repo->objects);
492492

493493
/*
494494
* Ok we have prepared all new packfiles.

builtin/upload-archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#define USE_THE_REPOSITORY_VARIABLE
55
#include "builtin.h"
66
#include "archive.h"
7-
#include "path.h"
87
#include "pkt-line.h"
8+
#include "setup.h"
99
#include "sideband.h"
1010
#include "run-command.h"
1111
#include "strvec.h"

builtin/upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
#include "gettext.h"
66
#include "pkt-line.h"
77
#include "parse-options.h"
8-
#include "path.h"
98
#include "protocol.h"
109
#include "replace-object.h"
1110
#include "upload-pack.h"
1211
#include "serve.h"
12+
#include "setup.h"
1313
#include "commit.h"
1414
#include "environment.h"
1515

chdir-notify.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ void chdir_notify_register(const char *name,
2525
list_add_tail(&e->list, &chdir_notify_entries);
2626
}
2727

28+
void chdir_notify_unregister(const char *name, chdir_notify_callback cb,
29+
void *data)
30+
{
31+
struct list_head *pos, *p;
32+
33+
list_for_each_safe(pos, p, &chdir_notify_entries) {
34+
struct chdir_notify_entry *e =
35+
list_entry(pos, struct chdir_notify_entry, list);
36+
37+
if (e->cb != cb || e->data != data || !e->name != !name ||
38+
(e->name && strcmp(e->name, name)))
39+
continue;
40+
41+
list_del(pos);
42+
free(e);
43+
}
44+
}
45+
2846
static void reparent_cb(const char *name,
2947
const char *old_cwd,
3048
const char *new_cwd,

chdir-notify.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ typedef void (*chdir_notify_callback)(const char *name,
4141
const char *new_cwd,
4242
void *data);
4343
void chdir_notify_register(const char *name, chdir_notify_callback cb, void *data);
44+
void chdir_notify_unregister(const char *name, chdir_notify_callback cb,
45+
void *data);
4446
void chdir_notify_reparent(const char *name, char **path);
4547

4648
/*

fsck.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,12 @@ int fsck_finish(struct fsck_options *options)
13791379
return ret;
13801380
}
13811381

1382+
bool fsck_has_queued_checks(struct fsck_options *options)
1383+
{
1384+
return !oidset_equal(&options->gitmodules_found, &options->gitmodules_done) ||
1385+
!oidset_equal(&options->gitattributes_found, &options->gitattributes_done);
1386+
}
1387+
13821388
void fsck_options_clear(struct fsck_options *options)
13831389
{
13841390
free(options->msg_type);

0 commit comments

Comments
 (0)