Re: [PATCH 1/3] Use startup_info->prefix rather than prefix.

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH 1/3] Use startup_info->prefix rather than prefix.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:53:12

Jared Hance [off-list ref] writes:
In trace_repo_setup, prefix is passed in as startup_info->prefix. But, as
indicated but a FIXME comment, trace_repo_setup has access to
startup_info. The prefix parameter has therefor been eliminated.

Signed-off-by: Jared Hance <redacted>
---
This comes from a9ca8a8 (builtins: print setup info if repo is found,
2010-11-26) and hasn't ever changed over time, even across f07d6a1 (setup:
save prefix (original cwd relative to toplevel) in startup_info,
2010-12-01) that did add the necessary "prefix" field to the startup_info
and was done reasonably close to the patch that wanted to have the field
in the first place.

The fix looks too easy to be correct X-<; in other words, I find it hard
to believe that such a triviality was left without a good reason, but I do
not think of any.

Well, but perhaps something too good to be true is indeed true sometimes.
quoted hunk
 cache.h |    2 +-
 git.c   |    2 +-
 trace.c |   10 +++++-----
 3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/cache.h b/cache.h
index e12b15f..baa8852 100644
--- a/cache.h
+++ b/cache.h
@@ -1211,7 +1211,7 @@ extern void trace_printf(const char *format, ...);
 extern void trace_vprintf(const char *key, const char *format, va_list ap);
 __attribute__((format (printf, 2, 3)))
 extern void trace_argv_printf(const char **argv, const char *format, ...);
-extern void trace_repo_setup(const char *prefix);
+extern void trace_repo_setup(void);
 extern int trace_want(const char *key);
 extern void trace_strbuf(const char *key, const struct strbuf *buf);
 
diff --git a/git.c b/git.c
index 3805616..7dcc527 100644
--- a/git.c
+++ b/git.c
@@ -296,7 +296,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 
 		if ((p->option & (RUN_SETUP | RUN_SETUP_GENTLY)) &&
 		    startup_info->have_repository) /* get_git_dir() may set up repo, avoid that */
-			trace_repo_setup(prefix);
+			trace_repo_setup();
 	}
 	commit_pager_choice();
 
diff --git a/trace.c b/trace.c index d953416..ebacf24 100644 ---
a/trace.c +++ b/trace.c @@ -152,8 +152,7 @@ static const char
*quote_crnl(const char *path) return new_path;
 }
 
-/* FIXME: move prefix to startup_info struct and get rid of this arg */
-void trace_repo_setup(const char *prefix)
+void trace_repo_setup(void)
 {
 	static const char *key = "GIT_TRACE_SETUP";
 	const char *git_work_tree;
@@ -168,13 +167,14 @@ void trace_repo_setup(const char *prefix)
 	if (!(git_work_tree = get_git_work_tree()))
 		git_work_tree = "(null)";
 
-	if (!prefix)
-		prefix = "(null)";
+	if (!startup_info->prefix)
+		startup_info->prefix = "(null)";
 
 	trace_printf_key(key, "setup: git_dir: %s\n", quote_crnl(get_git_dir()));
 	trace_printf_key(key, "setup: worktree: %s\n", quote_crnl(git_work_tree));
 	trace_printf_key(key, "setup: cwd: %s\n", quote_crnl(cwd));
-	trace_printf_key(key, "setup: prefix: %s\n", quote_crnl(prefix));
+	trace_printf_key(key, "setup: prefix: %s\n", 
+			 quote_crnl(startup_info->prefix));
 }
 
 int trace_want(const char *key)

Re: [PATCH 1/3] Use startup_info->prefix rather than prefix.

From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:53:12

2012/3/3 Junio C Hamano [off-list ref]:
Jared Hance [off-list ref] writes:
quoted
In trace_repo_setup, prefix is passed in as startup_info->prefix. But, as
indicated but a FIXME comment, trace_repo_setup has access to
startup_info. The prefix parameter has therefor been eliminated.

Signed-off-by: Jared Hance <redacted>
---
This comes from a9ca8a8 (builtins: print setup info if repo is found,
2010-11-26) and hasn't ever changed over time, even across f07d6a1 (setup:
save prefix (original cwd relative to toplevel) in startup_info,
2010-12-01) that did add the necessary "prefix" field to the startup_info
and was done reasonably close to the patch that wanted to have the field
in the first place.

The fix looks too easy to be correct X-<; in other words, I find it hard
to believe that such a triviality was left without a good reason, but I do
not think of any.

Well, but perhaps something too good to be true is indeed true sometimes.
This patch makes this function only usable when startup_info pointer
is initialized. As "git" binary is the only caller, the change is ok.
If non-builtin commands want to use this function, they need to
initialize startup_info first.
-- 
Duy
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help