git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/3] trace: omit repository discovery report
Date: Tue, 25 Jan 2011 18:59:16 -0600	[thread overview]
Message-ID: <20110126005916.GC11230@burratino> (raw)
In-Reply-To: <20110126004915.GA11230@burratino>

The run-command library advertises what process it is running through
the GIT_TRACE stream (see 575ba9d6, 2006-06-25) to provide context
during debugging for error messages that might come from the child
process.  In the same spirit, since v1.7.4-rc0~4^2~46 (builtins: print
setup info if repo is found, 2010-11-26) the repo-setup library prints
its result to GIT_TRACE, so the cwd, location of the git directory,
and so on are readily available during debug.

In practice, four extra lines of trace output per git process is too
much noise.  So stop printing repository discovery info except when
running tests.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 .gitignore            |    1 +
 Makefile              |    1 +
 git.c                 |   53 -------------------------------------------
 t/t1510-repo-setup.sh |    2 +-
 test-repo-setup.c     |   60 +++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 54 deletions(-)
 create mode 100644 test-repo-setup.c

diff --git a/.gitignore b/.gitignore
index 3dd6ef7..e1fc557 100644
--- a/.gitignore
+++ b/.gitignore
@@ -173,6 +173,7 @@
 /test-obj-pool
 /test-parse-options
 /test-path-utils
+/test-repo-setup
 /test-run-command
 /test-sha1
 /test-sigchain
diff --git a/Makefile b/Makefile
index 775ee83..01cc5c0 100644
--- a/Makefile
+++ b/Makefile
@@ -427,6 +427,7 @@ TEST_PROGRAMS_NEED_X += test-match-trees
 TEST_PROGRAMS_NEED_X += test-obj-pool
 TEST_PROGRAMS_NEED_X += test-parse-options
 TEST_PROGRAMS_NEED_X += test-path-utils
+TEST_PROGRAMS_NEED_X += test-repo-setup
 TEST_PROGRAMS_NEED_X += test-run-command
 TEST_PROGRAMS_NEED_X += test-sha1
 TEST_PROGRAMS_NEED_X += test-sigchain
diff --git a/git.c b/git.c
index d1b15f1..d532576 100644
--- a/git.c
+++ b/git.c
@@ -238,55 +238,6 @@ 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)
@@ -324,10 +275,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)
 			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();
 	}
 	commit_pager_choice();
 
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index 15101d5..c2edf6f 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -57,7 +57,7 @@ test_repo () {
 			export GIT_WORK_TREE
 		fi &&
 		rm -f trace &&
-		GIT_TRACE="$(pwd)/trace" git symbolic-ref HEAD >/dev/null &&
+		GIT_TRACE="$(pwd)/trace" test-repo-setup &&
 		grep '^setup: ' trace >result &&
 		test_cmp expected result
 	)
diff --git a/test-repo-setup.c b/test-repo-setup.c
new file mode 100644
index 0000000..3b66237
--- /dev/null
+++ b/test-repo-setup.c
@@ -0,0 +1,60 @@
+#include "cache.h"
+
+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));
+}
+
+int main(int argc, char **argv)
+{
+	static struct startup_info test_startup_info;
+
+	startup_info = &test_startup_info;
+	setup_git_directory();
+	trace_repo_setup();
+	return 0;
+}
-- 
1.7.4.rc3

  parent reply	other threads:[~2011-01-26  0:59 UTC|newest]

Thread overview: 87+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-26 15:31 [PATCH 00/47] nd/setup updates on pu Nguyễn Thái Ngọc Duy
2010-11-26 15:31 ` [PATCH 01/47] builtins: print setup info if repo is found Nguyễn Thái Ngọc Duy
2011-01-26  0:49   ` [PATCH/RFC 0/3] trace: omit noisy repository discovery report Jonathan Nieder
2011-01-26  0:55     ` [PATCH 1/3] setup: do not expose tracing code Jonathan Nieder
2011-01-26  0:59     ` Jonathan Nieder [this message]
2011-01-26  1:19       ` [PATCH 2/3] trace: omit repository discovery report Sverre Rabbelier
2011-01-26  1:46         ` Jonathan Nieder
2011-01-26  1:53       ` Nguyen Thai Ngoc Duy
2011-01-26  1:01     ` [PATCH 3/3] tests: avoid unnecessary use of GIT_TRACE in repo-setup tests Jonathan Nieder
2011-01-26  1:45     ` [PATCH/RFC 0/3] trace: omit noisy repository discovery report Nguyen Thai Ngoc Duy
2011-01-26  5:07       ` Jeff King
2010-11-26 15:31 ` [PATCH 02/47] Add t1510 and basic rules that run repo setup Nguyễn Thái Ngọc Duy
2010-11-26 15:31 ` [PATCH 03/47] t1510: setup case #0 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 04/47] t1510: setup case #1 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 05/47] t1510: setup case #2 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 06/47] t1510: setup case #3 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 07/47] t1510: setup case #4 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 08/47] t1510: setup case #5 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 09/47] t1510: setup case #6 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 10/47] t1510: setup case #7 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 11/47] t1510: setup case #8 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 12/47] t1510: setup case #9 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 13/47] t1510: setup case #10 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 14/47] t1510: setup case #11 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 15/47] t1510: setup case #12 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 16/47] t1510: setup case #13 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 17/47] t1510: setup case #14 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 18/47] t1510: setup case #15 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 19/47] t1510: setup case #16 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 20/47] t1510: setup case #17 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 21/47] t1510: setup case #18 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 22/47] t1510: setup case #19 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 23/47] t1510: setup case #20 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 24/47] t1510: setup case #21 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 25/47] t1510: setup case #22 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 26/47] t1510: setup case #23 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 27/47] t1510: setup case #24 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 28/47] t1510: setup case #25 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 29/47] t1510: setup case #26 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 30/47] t1510: setup case #27 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 31/47] t1510: setup case #28 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 32/47] t1510: setup case #29 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 33/47] t1510: setup case #30 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 34/47] t1510: setup case #31 Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 35/47] git-rev-parse.txt: clarify --git-dir Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 36/47] rev-parse: prints --git-dir relative to user's cwd Nguyễn Thái Ngọc Duy
2010-12-22  1:56   ` Junio C Hamano
2010-12-22  7:05     ` Nguyen Thai Ngoc Duy
2010-11-26 15:32 ` [PATCH 37/47] Add git_config_early() Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 38/47] Use git_config_early() instead of git_config() during repo setup Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 39/47] setup: limit get_git_work_tree()'s to explicit setup case only Nguyễn Thái Ngọc Duy
2011-01-18  7:44   ` Jonathan Nieder
2011-01-18 13:59     ` Nguyen Thai Ngoc Duy
2011-01-18 19:41     ` Junio C Hamano
2011-01-19  1:58       ` Nguyen Thai Ngoc Duy
2011-01-19 12:37       ` [PATCH/RFC 0/3] setup: stop ignoring GIT_WORK_TREE (when GIT_DIR is unset) Jonathan Nieder
2011-01-19 12:38         ` [PATCH 1/3] tests: cosmetic improvements to the repo-setup test Jonathan Nieder
2011-01-19 12:42         ` [PATCH 3/3] setup: always honor GIT_WORK_TREE and core.worktree Jonathan Nieder
2011-01-19 14:48           ` Nguyen Thai Ngoc Duy
2011-01-19 19:31             ` Jonathan Nieder
2011-01-19 20:17               ` Junio C Hamano
2011-01-21 20:58                 ` Junio C Hamano
2011-01-21 22:02                   ` Junio C Hamano
2011-01-21 22:05                     ` Jonathan Nieder
2011-01-21 23:01                       ` Junio C Hamano
2011-01-22 10:30                   ` Nguyen Thai Ngoc Duy
2011-01-23 23:49                     ` Junio C Hamano
2011-01-24  8:45                       ` Jonathan Nieder
2011-01-19 18:51           ` Maaartin
2011-01-19 19:24             ` Junio C Hamano
2011-01-19 20:35               ` Maaartin
2011-01-19 20:52                 ` checkout to other directory (Re: [PATCH 3/3] setup: always honor GIT_WORK_TREE and core.worktree) Jonathan Nieder
2011-01-19 19:03           ` [PATCH 3/3] setup: always honor GIT_WORK_TREE and core.worktree Jonathan Nieder
2011-01-19 19:13           ` Junio C Hamano
2011-01-19 13:05         ` [PATCH/RFC 0/3] setup: stop ignoring GIT_WORK_TREE (when GIT_DIR is unset) Jonathan Nieder
2010-11-26 15:32 ` [PATCH 40/47] setup: clean up setup_bare_git_dir() Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 41/47] t1020-subdirectory: test alias expansion in a subdirectory Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 42/47] setup: clean up setup_discovered_git_dir() Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 43/47] setup: rework setup_explicit_git_dir() Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 44/47] Remove all logic from get_git_work_tree() Nguyễn Thái Ngọc Duy
2010-12-22  1:56   ` Junio C Hamano
2010-12-22  7:22     ` Nguyen Thai Ngoc Duy
2010-12-22 15:17       ` Junio C Hamano
2010-11-26 15:32 ` [PATCH 45/47] t0001: test git init when run via an alias Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 46/47] Revert "Documentation: always respect core.worktree if set" Nguyễn Thái Ngọc Duy
2010-11-26 15:32 ` [PATCH 47/47] git.txt: correct where --work-tree path is relative to Nguyễn Thái Ngọc Duy
2010-11-29 21:29 ` [PATCH 00/47] nd/setup updates on pu Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110126005916.GC11230@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).