Skip to content

Commit 78f2210

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 169c979 commit 78f2210

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

builtin/count-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int cmd_count_objects(int argc, const char **argv, const char *prefix)
113113
usage_with_options(count_objects_usage, opts);
114114
if (verbose) {
115115
report_garbage = real_report_garbage;
116-
report_linked_checkout_garbage();
116+
report_linked_checkout_garbage(the_repository);
117117
}
118118

119119
for_each_loose_file_in_objdir(get_object_directory(),

path.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,15 +365,15 @@ static void update_common_dir(struct strbuf *buf, int git_dir_len,
365365
strbuf_addstr(buf, LOCK_SUFFIX);
366366
}
367367

368-
void report_linked_checkout_garbage(void)
368+
void report_linked_checkout_garbage(struct repository *r)
369369
{
370370
struct strbuf sb = STRBUF_INIT;
371371
const struct common_dir *p;
372372
int len;
373373

374-
if (!the_repository->different_commondir)
374+
if (!r->different_commondir)
375375
return;
376-
strbuf_addf(&sb, "%s/", get_git_dir());
376+
strbuf_addf(&sb, "%s/", r->gitdir);
377377
len = sb.len;
378378
for (p = common_list; p->path; p++) {
379379
const char *path = p->path;

path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
158158
const char *fmt, ...)
159159
__attribute__((format (printf, 3, 4)));
160160

161-
void report_linked_checkout_garbage(void);
161+
void report_linked_checkout_garbage(struct repository *r);
162162

163163
/*
164164
* You can define a static memoized git path like:

0 commit comments

Comments
 (0)