trace: stop using `the_repository`
Stop using `the_repository` in the "trace" subsystem by passing in a repository when setting up tracing. Adjust the only caller accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Dec 17, 2024 at 07:43 UTC
bd0c0fb790dcb6cd32a585e1d9fcb0a4a4f7379b
3 files changed
+8
-7
git.c
+1
-1
@@ -467,7 +467,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
467
use_pager = 1;
468
if (run_setup && startup_info->have_repository)
469
/* get_git_dir() may set up repo, avoid that */
470
- trace_repo_setup();
470
+ trace_repo_setup(the_repository);
471
commit_pager_choice();
472
473
if (!help && p->option & NEED_WORK_TREE)
trace.c
+4
-5
@@ -21,7 +21,6 @@
21
* along with this program; if not, see <https://www.gnu.org/licenses/>.
22
*/
23
24
-#define USE_THE_REPOSITORY_VARIABLE
24
#define DISABLE_SIGN_COMPARE_WARNINGS
25
26
#include "git-compat-util.h"
@@ -298,7 +297,7 @@ static const char *quote_crnl(const char *path)
297
return new_path.buf;
298
}
299
301
-void trace_repo_setup(void)
300
+void trace_repo_setup(struct repository *r)
301
{
302
const char *git_work_tree, *prefix = startup_info->prefix;
303
char *cwd;
@@ -308,14 +307,14 @@ void trace_repo_setup(void)
307
308
cwd = xgetcwd();
309
311
- if (!(git_work_tree = repo_get_work_tree(the_repository)))
310
+ if (!(git_work_tree = repo_get_work_tree(r)))
311
git_work_tree = "(null)";
312
313
if (!startup_info->prefix)
314
prefix = "(null)";
315
317
- trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(repo_get_git_dir(the_repository)));
318
- trace_printf_key(&trace_setup_key, "setup: git_common_dir: %s\n", quote_crnl(repo_get_common_dir(the_repository)));
316
+ trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(repo_get_git_dir(r)));
317
+ trace_printf_key(&trace_setup_key, "setup: git_common_dir: %s\n", quote_crnl(repo_get_common_dir(r)));
318
trace_printf_key(&trace_setup_key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
319
trace_printf_key(&trace_setup_key, "setup: cwd: %s\n", quote_crnl(cwd));
320
trace_printf_key(&trace_setup_key, "setup: prefix: %s\n", quote_crnl(prefix));
trace.h
+3
-1
@@ -92,7 +92,9 @@ extern struct trace_key trace_default_key;
92
extern struct trace_key trace_perf_key;
93
extern struct trace_key trace_setup_key;
94
95
-void trace_repo_setup(void);
95
+struct repository;
96
+
97
+void trace_repo_setup(struct repository *r);
98
99
/**
100
* Checks whether the trace key is enabled. Used to prevent expensive