The trace_repo_setup function has only one caller (run_builtin) which lives in git.c. Move the code there and stop advertising it in cache.h. This means it is likely to remain safe to use startup_info within trace_repo_setup, since the trace_repo_setup function is only used when running builtins. Do so and drop the "prefix" parameter. Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx> --- cache.h | 1 - git.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- trace.c | 49 ------------------------------------------------- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/cache.h b/cache.h index d83d68c..2eb3ccc 100644 --- a/cache.h +++ b/cache.h @@ -1067,7 +1067,6 @@ __attribute__((format (printf, 1, 2))) extern void trace_printf(const char *format, ...); __attribute__((format (printf, 2, 3))) extern void trace_argv_printf(const char **argv, const char *format, ...); -extern void trace_repo_setup(const char *prefix); /* convert.c */ /* returns 1 if *dst was used */ diff --git a/git.c b/git.c index 68334f6..d1b15f1 100644 --- a/git.c +++ b/git.c @@ -238,6 +238,55 @@ static int handle_alias(int *argcp, const char ***argv) return ret; } +static const char *quote_crnl(const char *path) +{ + static char new_path[PATH_MAX]; + const char *p2 = path; + char *p1 = new_path; + + if (!path) + return NULL; + + while (*p2) { + switch (*p2) { + case '\\': *p1++ = '\\'; *p1++ = '\\'; break; + case '\n': *p1++ = '\\'; *p1++ = 'n'; break; + case '\r': *p1++ = '\\'; *p1++ = 'r'; break; + default: + *p1++ = *p2; + } + p2++; + } + *p1 = '\0'; + return new_path; +} + +static void trace_repo_setup(void) +{ + const char *git_work_tree; + const char *prefix = startup_info->prefix; + char cwd[PATH_MAX]; + char *trace = getenv("GIT_TRACE"); + + if (!trace || !strcmp(trace, "") || + !strcmp(trace, "0") || !strcasecmp(trace, "false")) + return; + + if (!getcwd(cwd, PATH_MAX)) + die("Unable to get current working directory"); + + if (!(git_work_tree = get_git_work_tree())) + git_work_tree = "(null)"; + + if (!prefix) + prefix = "(null)"; + + trace_printf("setup: git_dir: %s\n", quote_crnl(get_git_dir())); + trace_printf("setup: worktree: %s\n", quote_crnl(git_work_tree)); + trace_printf("setup: cwd: %s\n", quote_crnl(cwd)); + trace_printf("setup: prefix: %s\n", quote_crnl(prefix)); +} + const char git_version_string[] = GIT_VERSION; #define RUN_SETUP (1<<0) @@ -278,7 +327,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 35d388d..0fb2a2c 100644 --- a/trace.c +++ b/trace.c @@ -127,52 +127,3 @@ void trace_argv_printf(const char **argv, const char *fmt, ...) if (need_close) close(fd); } - -static const char *quote_crnl(const char *path) -{ - static char new_path[PATH_MAX]; - const char *p2 = path; - char *p1 = new_path; - - if (!path) - return NULL; - - while (*p2) { - switch (*p2) { - case '\\': *p1++ = '\\'; *p1++ = '\\'; break; - case '\n': *p1++ = '\\'; *p1++ = 'n'; break; - case '\r': *p1++ = '\\'; *p1++ = 'r'; break; - default: - *p1++ = *p2; - } - p2++; - } - *p1 = '\0'; - return new_path; -} - -/* FIXME: move prefix to startup_info struct and get rid of this arg */ -void trace_repo_setup(const char *prefix) -{ - const char *git_work_tree; - char cwd[PATH_MAX]; - char *trace = getenv("GIT_TRACE"); - - if (!trace || !strcmp(trace, "") || - !strcmp(trace, "0") || !strcasecmp(trace, "false")) - return; - - if (!getcwd(cwd, PATH_MAX)) - die("Unable to get current working directory"); - - if (!(git_work_tree = get_git_work_tree())) - git_work_tree = "(null)"; - - if (!prefix) - prefix = "(null)"; - - trace_printf("setup: git_dir: %s\n", quote_crnl(get_git_dir())); - trace_printf("setup: worktree: %s\n", quote_crnl(git_work_tree)); - trace_printf("setup: cwd: %s\n", quote_crnl(cwd)); - trace_printf("setup: prefix: %s\n", quote_crnl(prefix)); -} -- 1.7.4.rc3 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html