path: stop relying on `the_repository` when reporting garbage
We access `the_repository` in `report_linked_checkout_garbage()` both directly and indirectly via `get_git_dir()`. Remove this dependency by instead passing a `struct repository` as parameter. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Aug 13, 2024 at 11:13 UTC
78f2210b3c8605144d62a90b58e888312f64efc8
3 files changed
+5
-5
builtin/count-objects.c
+1
-1
@@ -113,7 +113,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
113
usage_with_options(count_objects_usage, opts);
114
if (verbose) {
115
report_garbage = real_report_garbage;
116
- report_linked_checkout_garbage();
116
+ report_linked_checkout_garbage(the_repository);
117
}
118
119
for_each_loose_file_in_objdir(get_object_directory(),
path.c
+3
-3
@@ -365,15 +365,15 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len,
365
strbuf_addstr(buf, LOCK_SUFFIX);
366
}
367
368
-void report_linked_checkout_garbage(void)
368
+void report_linked_checkout_garbage(struct repository *r)
369
{
370
struct strbuf sb = STRBUF_INIT;
371
const struct common_dir *p;
372
int len;
373
374
- if (!the_repository->different_commondir)
374
+ if (!r->different_commondir)
375
return;
376
- strbuf_addf(&sb, "%s/", get_git_dir());
376
+ strbuf_addf(&sb, "%s/", r->gitdir);
377
len = sb.len;
378
for (p = common_list; p->path; p++) {
379
const char *path = p->path;
path.h
+1
-1
@@ -158,7 +158,7 @@ int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
158
const char *fmt, ...)
159
__attribute__((format (printf, 3, 4)));
160
161
-void report_linked_checkout_garbage(void);
161
+void report_linked_checkout_garbage(struct repository *r);
162
163
/*
164
* You can define a static memoized git path like: