Skip to content

Commit bd0c0fb

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

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
467467
use_pager = 1;
468468
if (run_setup && startup_info->have_repository)
469469
/* get_git_dir() may set up repo, avoid that */
470-
trace_repo_setup();
470+
trace_repo_setup(the_repository);
471471
commit_pager_choice();
472472

473473
if (!help && p->option & NEED_WORK_TREE)

trace.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* along with this program; if not, see <https://www.gnu.org/licenses/>.
2222
*/
2323

24-
#define USE_THE_REPOSITORY_VARIABLE
2524
#define DISABLE_SIGN_COMPARE_WARNINGS
2625

2726
#include "git-compat-util.h"
@@ -298,7 +297,7 @@ static const char *quote_crnl(const char *path)
298297
return new_path.buf;
299298
}
300299

301-
void trace_repo_setup(void)
300+
void trace_repo_setup(struct repository *r)
302301
{
303302
const char *git_work_tree, *prefix = startup_info->prefix;
304303
char *cwd;
@@ -308,14 +307,14 @@ void trace_repo_setup(void)
308307

309308
cwd = xgetcwd();
310309

311-
if (!(git_work_tree = repo_get_work_tree(the_repository)))
310+
if (!(git_work_tree = repo_get_work_tree(r)))
312311
git_work_tree = "(null)";
313312

314313
if (!startup_info->prefix)
315314
prefix = "(null)";
316315

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)));
319318
trace_printf_key(&trace_setup_key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
320319
trace_printf_key(&trace_setup_key, "setup: cwd: %s\n", quote_crnl(cwd));
321320
trace_printf_key(&trace_setup_key, "setup: prefix: %s\n", quote_crnl(prefix));

trace.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ extern struct trace_key trace_default_key;
9292
extern struct trace_key trace_perf_key;
9393
extern struct trace_key trace_setup_key;
9494

95-
void trace_repo_setup(void);
95+
struct repository;
96+
97+
void trace_repo_setup(struct repository *r);
9698

9799
/**
98100
* Checks whether the trace key is enabled. Used to prevent expensive

0 commit comments

Comments
 (0)