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

[PATCH 3/3] tests: avoid unnecessary use of GIT_TRACE in repo-setup tests

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 26, 2011, 01:01 UTC
Message-ID
<20110126010147.GD11230@burratino>
In-Reply-To
<20110126004915.GA11230@burratino>

Now that the startup info is printed by a separate helper, there is no need to mark that output with "setup: " or use an environment variable to request it.

While we're changing the test-repo-setup output format, stop quoting newlines to give the tests a chance of passing when $TEST_DIRECTORY contains a newline or backslash.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Thanks for reading.
 t/t1510-repo-setup.sh |   12 +++++-------
 test-repo-setup.c     |   40 ++++++----------------------------------
 2 files changed, 11 insertions(+), 41 deletions(-)
diff --git a/t/t1510-repo-setup.sh b/t/t1510-repo-setup.sh
index c2edf6f..a8cb445 100755
--- a/t/t1510-repo-setup.sh
+++ b/t/t1510-repo-setup.sh
@@ -56,9 +56,7 @@ test_repo () {
 			GIT_WORK_TREE="$3" &&
 			export GIT_WORK_TREE
 		fi &&
-		rm -f trace &&
-		GIT_TRACE="$(pwd)/trace" test-repo-setup &&
-		grep '^setup: ' trace >result &&
+		test-repo-setup >result &&
 		test_cmp expected result
 	)
 }
@@ -105,10 +103,10 @@ setup_env () {
 
 expect () {
 	cat >"$1/expected" <<-EOF
-	setup: git_dir: $2
-	setup: worktree: $3
-	setup: cwd: $4
-	setup: prefix: $5
+	git_dir: $2
+	worktree: $3
+	cwd: $4
+	prefix: $5
 	EOF
 }
 
diff --git a/test-repo-setup.c b/test-repo-setup.c
index 3b66237..72d35fe 100644
--- a/test-repo-setup.c
+++ b/test-repo-setup.c
@@ -1,52 +1,24 @@
 #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 *git_work_tree = get_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()))
+	if (!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));
+	printf("git_dir: %s\n", get_git_dir());
+	printf("worktree: %s\n", git_work_tree);
+	printf("cwd: %s\n", cwd);
+	printf("prefix: %s\n", prefix);
 }
 
 int main(int argc, char **argv)
-- 
1.7.4.rc3
Previous: Nguyen Thai Ngoc DuyNext: Nguyen Thai Ngoc Duy
Message 9 of 87 in “nd/setup updates on pu”
  1. 00/47 nd/setup updates on puNguyễn Thái Ngọc Duy, Nov 26, 2010
  2. 01/47 builtins: print setup info if repo is foundNguyễn Thái Ngọc Duy, Nov 26, 2010
  3. 0/3 trace: omit noisy repository discovery reportJonathan Nieder, Jan 26, 2011
  4. 1/3 setup: do not expose tracing codeJonathan Nieder, Jan 26, 2011
  5. 2/3 trace: omit repository discovery reportJonathan Nieder, Jan 26, 2011
  6. Sverre RabbelierJan 26, 2011
  7. Jonathan NiederJan 26, 2011
  8. Nguyen Thai Ngoc DuyJan 26, 2011
  9. 3/3 tests: avoid unnecessary use of GIT_TRACE in repo-setup testsJonathan Nieder, Jan 26, 2011
  10. Nguyen Thai Ngoc DuyJan 26, 2011
  11. Jeff KingJan 26, 2011
  12. 02/47 Add t1510 and basic rules that run repo setupNguyễn Thái Ngọc Duy, Nov 26, 2010
  13. 03/47 t1510: setup case #0Nguyễn Thái Ngọc Duy, Nov 26, 2010
  14. 04/47 t1510: setup case #1Nguyễn Thái Ngọc Duy, Nov 26, 2010
  15. 05/47 t1510: setup case #2Nguyễn Thái Ngọc Duy, Nov 26, 2010
  16. 06/47 t1510: setup case #3Nguyễn Thái Ngọc Duy, Nov 26, 2010
  17. 07/47 t1510: setup case #4Nguyễn Thái Ngọc Duy, Nov 26, 2010
  18. 08/47 t1510: setup case #5Nguyễn Thái Ngọc Duy, Nov 26, 2010
  19. 09/47 t1510: setup case #6Nguyễn Thái Ngọc Duy, Nov 26, 2010
  20. 10/47 t1510: setup case #7Nguyễn Thái Ngọc Duy, Nov 26, 2010
  21. 11/47 t1510: setup case #8Nguyễn Thái Ngọc Duy, Nov 26, 2010
  22. 12/47 t1510: setup case #9Nguyễn Thái Ngọc Duy, Nov 26, 2010
  23. 13/47 t1510: setup case #10Nguyễn Thái Ngọc Duy, Nov 26, 2010
  24. 14/47 t1510: setup case #11Nguyễn Thái Ngọc Duy, Nov 26, 2010
  25. 15/47 t1510: setup case #12Nguyễn Thái Ngọc Duy, Nov 26, 2010
  26. 16/47 t1510: setup case #13Nguyễn Thái Ngọc Duy, Nov 26, 2010
  27. 17/47 t1510: setup case #14Nguyễn Thái Ngọc Duy, Nov 26, 2010
  28. 18/47 t1510: setup case #15Nguyễn Thái Ngọc Duy, Nov 26, 2010
  29. 19/47 t1510: setup case #16Nguyễn Thái Ngọc Duy, Nov 26, 2010
  30. 20/47 t1510: setup case #17Nguyễn Thái Ngọc Duy, Nov 26, 2010
  31. 21/47 t1510: setup case #18Nguyễn Thái Ngọc Duy, Nov 26, 2010
  32. 22/47 t1510: setup case #19Nguyễn Thái Ngọc Duy, Nov 26, 2010
  33. 23/47 t1510: setup case #20Nguyễn Thái Ngọc Duy, Nov 26, 2010
  34. 24/47 t1510: setup case #21Nguyễn Thái Ngọc Duy, Nov 26, 2010
  35. 25/47 t1510: setup case #22Nguyễn Thái Ngọc Duy, Nov 26, 2010
  36. 26/47 t1510: setup case #23Nguyễn Thái Ngọc Duy, Nov 26, 2010
  37. 27/47 t1510: setup case #24Nguyễn Thái Ngọc Duy, Nov 26, 2010
  38. 28/47 t1510: setup case #25Nguyễn Thái Ngọc Duy, Nov 26, 2010
  39. 29/47 t1510: setup case #26Nguyễn Thái Ngọc Duy, Nov 26, 2010
  40. 30/47 t1510: setup case #27Nguyễn Thái Ngọc Duy, Nov 26, 2010
  41. 31/47 t1510: setup case #28Nguyễn Thái Ngọc Duy, Nov 26, 2010
  42. 32/47 t1510: setup case #29Nguyễn Thái Ngọc Duy, Nov 26, 2010
  43. 33/47 t1510: setup case #30Nguyễn Thái Ngọc Duy, Nov 26, 2010
  44. 34/47 t1510: setup case #31Nguyễn Thái Ngọc Duy, Nov 26, 2010
  45. 35/47 git-rev-parse.txt: clarify --git-dirNguyễn Thái Ngọc Duy, Nov 26, 2010
  46. 36/47 rev-parse: prints --git-dir relative to user's cwdNguyễn Thái Ngọc Duy, Nov 26, 2010
  47. Junio C HamanoDec 22, 2010
  48. Nguyen Thai Ngoc DuyDec 22, 2010
  49. 37/47 Add git_config_early()Nguyễn Thái Ngọc Duy, Nov 26, 2010
  50. 38/47 Use git_config_early() instead of git_config() during repo setupNguyễn Thái Ngọc Duy, Nov 26, 2010
  51. 39/47 setup: limit get_git_work_tree()'s to explicit setup case onlyNguyễn Thái Ngọc Duy, Nov 26, 2010
  52. Jonathan NiederJan 18, 2011
  53. Nguyen Thai Ngoc DuyJan 18, 2011
  54. Junio C HamanoJan 18, 2011
  55. Nguyen Thai Ngoc DuyJan 19, 2011
  56. 0/3 setup: stop ignoring GIT_WORK_TREE (when GIT_DIR is unset)Jonathan Nieder, Jan 19, 2011
  57. 1/3 tests: cosmetic improvements to the repo-setup testJonathan Nieder, Jan 19, 2011
  58. 3/3 setup: always honor GIT_WORK_TREE and core.worktreeJonathan Nieder, Jan 19, 2011
  59. Nguyen Thai Ngoc DuyJan 19, 2011
  60. Jonathan NiederJan 19, 2011
  61. Junio C HamanoJan 19, 2011
  62. Junio C HamanoJan 21, 2011
  63. Junio C HamanoJan 21, 2011
  64. Jonathan NiederJan 21, 2011
  65. Junio C HamanoJan 21, 2011
  66. Nguyen Thai Ngoc DuyJan 22, 2011
  67. Junio C HamanoJan 23, 2011
  68. Jonathan NiederJan 24, 2011
  69. MaaartinJan 19, 2011
  70. Junio C HamanoJan 19, 2011
  71. MaaartinJan 19, 2011
  72. checkout to other directory (Re: [PATCH 3/3] setup: always honor GIT_WORK_TREE and core.worktree)Jonathan Nieder, Jan 19, 2011
  73. Jonathan NiederJan 19, 2011
  74. Junio C HamanoJan 19, 2011
  75. Jonathan NiederJan 19, 2011
  76. 40/47 setup: clean up setup_bare_git_dir()Nguyễn Thái Ngọc Duy, Nov 26, 2010
  77. 41/47 t1020-subdirectory: test alias expansion in a subdirectoryNguyễn Thái Ngọc Duy, Nov 26, 2010
  78. 42/47 setup: clean up setup_discovered_git_dir()Nguyễn Thái Ngọc Duy, Nov 26, 2010
  79. 43/47 setup: rework setup_explicit_git_dir()Nguyễn Thái Ngọc Duy, Nov 26, 2010
  80. 44/47 Remove all logic from get_git_work_tree()Nguyễn Thái Ngọc Duy, Nov 26, 2010
  81. Junio C HamanoDec 22, 2010
  82. Nguyen Thai Ngoc DuyDec 22, 2010
  83. Junio C HamanoDec 22, 2010
  84. 45/47 t0001: test git init when run via an aliasNguyễn Thái Ngọc Duy, Nov 26, 2010
  85. 46/47 Revert "Documentation: always respect core.worktree if set"Nguyễn Thái Ngọc Duy, Nov 26, 2010
  86. 47/47 git.txt: correct where --work-tree path is relative toNguyễn Thái Ngọc Duy, Nov 26, 2010
  87. Junio C HamanoNov 29, 2010

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.