summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7ebee44)
raw | patch | inline | side by side (parent: 7ebee44)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Fri, 26 Nov 2010 15:31:57 +0000 (22:31 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 29 Nov 2010 21:25:53 +0000 (13:25 -0800) |
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
cache.h | patch | blob | history | |
git.c | patch | blob | history | |
trace.c | patch | blob | history |
index 33decd942d4985c8efc1c75fd3fa2f4adf4a56ca..d1bee5d5186c4f1369d66c14a5ad49c5e36f7bf8 100644 (file)
--- a/cache.h
+++ b/cache.h
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 */
index 0409ac9fd3f1ea36680189e07116e58b2630ccad..6793178210db64ae59d3a4d401f32d6d3bd5b1a1 100644 (file)
--- a/git.c
+++ b/git.c
use_pager = check_pager_config(p->cmd);
if (use_pager == -1 && p->option & USE_PAGER)
use_pager = 1;
+
+ 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);
}
commit_pager_choice();
index 1e560cb0b977e19beeb095497c8e4f6280b7f0d6..bdb5d2fa77ed06bd5ea3ef33b827a6bd11618268 100644 (file)
--- a/trace.c
+++ b/trace.c
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)
+{
+ 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");
+
+ trace_printf("setup: git_dir: %s\n", quote_crnl(get_git_dir()));
+ trace_printf("setup: worktree: %s\n", quote_crnl(get_git_work_tree()));
+ trace_printf("setup: cwd: %s\n", quote_crnl(cwd));
+ trace_printf("setup: prefix: %s\n", quote_crnl(prefix));
+}