git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 03/14] trace: stop using `the_repository`

From
Patrick Steinhardt <ps@pks.im>
Date
Dec 17, 2024, 06:43 UTC
Message-ID
<20241217-pks-use-the-repository-conversion-v1-3-0dba48bcc239@pks.im>
In-Reply-To
<20241217-pks-use-the-repository-conversion-v1-0-0dba48bcc239@pks.im>

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>
---
 git.c   | 2 +-
 trace.c | 9 ++++-----
 trace.h | 4 +++-
 3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/git.c b/git.c
index d977ebc84cfba611c3e452cace3bda1ce13faf5d..a94dab3770251fa8b7b466daa85c2d61ca730670 100644
--- a/git.c
+++ b/git.c
@@ -467,7 +467,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv, struct
 		use_pager = 1;
 	if (run_setup && startup_info->have_repository)
 		/* get_git_dir() may set up repo, avoid that */
-		trace_repo_setup();
+		trace_repo_setup(the_repository);
 	commit_pager_choice();
 
 	if (!help && p->option & NEED_WORK_TREE)
diff --git a/trace.c b/trace.c
index 2cfd25942ee725b022e8dea26096f01f2164a407..9b99460db82a28634c09260b42f311f7c69f4d59 100644
--- a/trace.c
+++ b/trace.c
@@ -21,7 +21,6 @@
  *  along with this program; if not, see <https://www.gnu.org/licenses/>.
  */
 
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -298,7 +297,7 @@ static const char *quote_crnl(const char *path)
 	return new_path.buf;
 }
 
-void trace_repo_setup(void)
+void trace_repo_setup(struct repository *r)
 {
 	const char *git_work_tree, *prefix = startup_info->prefix;
 	char *cwd;
@@ -308,14 +307,14 @@ void trace_repo_setup(void)
 
 	cwd = xgetcwd();
 
-	if (!(git_work_tree = repo_get_work_tree(the_repository)))
+	if (!(git_work_tree = repo_get_work_tree(r)))
 		git_work_tree = "(null)";
 
 	if (!startup_info->prefix)
 		prefix = "(null)";
 
-	trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(repo_get_git_dir(the_repository)));
-	trace_printf_key(&trace_setup_key, "setup: git_common_dir: %s\n", quote_crnl(repo_get_common_dir(the_repository)));
+	trace_printf_key(&trace_setup_key, "setup: git_dir: %s\n", quote_crnl(repo_get_git_dir(r)));
+	trace_printf_key(&trace_setup_key, "setup: git_common_dir: %s\n", quote_crnl(repo_get_common_dir(r)));
 	trace_printf_key(&trace_setup_key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
 	trace_printf_key(&trace_setup_key, "setup: cwd: %s\n", quote_crnl(cwd));
 	trace_printf_key(&trace_setup_key, "setup: prefix: %s\n", quote_crnl(prefix));
diff --git a/trace.h b/trace.h
index d304d55aa1d706dc3f65bbf15c7b2506bc0e9499..9152fe9b3e565ee8dde1ddf185f30f021812a416 100644
--- a/trace.h
+++ b/trace.h
@@ -92,7 +92,9 @@ extern struct trace_key trace_default_key;
 extern struct trace_key trace_perf_key;
 extern struct trace_key trace_setup_key;
 
-void trace_repo_setup(void);
+struct repository;
+
+void trace_repo_setup(struct repository *r);
 
 /**
  * Checks whether the trace key is enabled. Used to prevent expensive
-- 
2.48.0.rc0.184.g0fc57dec57.dirty
Previous: Karthik NayakNext: Patrick Steinhardt
Message 9 of 26 in “Stop using `the_repository` in some trivial cases”
  1. 00/14 Stop using `the_repository` in some trivial casesPatrick Steinhardt, Dec 17, 2024
  2. 01/14 progress: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  3. Karthik NayakDec 31, 2024
  4. Toon ClaesJan 6, 2025
  5. Patrick SteinhardtJan 7, 2025
  6. 02/14 pager: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  7. shejialuoDec 17, 2024
  8. Karthik NayakDec 31, 2024
  9. 03/14 trace: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  10. 04/14 serve: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  11. 05/14 send-pack: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  12. 06/14 server-info: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  13. shejialuoDec 17, 2024
  14. 07/14 diagnose: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  15. 08/14 mailinfo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  16. 09/14 credential: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  17. 10/14 resolve-undo: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  18. 11/14 tmp-objdir: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  19. 12/14 add-interactive: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  20. 13/14 graph: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  21. 14/14 match-trees: stop using `the_repository`Patrick Steinhardt, Dec 17, 2024
  22. shejialuoDec 17, 2024
  23. Patrick SteinhardtDec 27, 2024
  24. Karthik NayakJan 7, 2025
  25. Toon ClaesJan 7, 2025
  26. Junio C HamanoJan 7, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.