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

Re: [PATCH] Adjust t5510 to put remotes in config

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Dec 19, 2006, 08:18 UTC
Message-ID
<Pine.LNX.4.63.0612190908060.19693@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7virg8vl74.fsf@assigned-by-dhcp.cox.net>
Hi,
On Mon, 18 Dec 2006, Junio C Hamano wrote:
> fix testsuite: make sure they use templates freshly built from the source
Okay.

But why not introduce the environment variable GIT_TEMPLATE_DIR, to imitate similar solutions. This would result in a smaller diff, and people would not have to remember typing "git_init_db" in tests (I admit, I did not spot the subtle difference right away, and thought they were white-space fixes...).

I.e. something like this instead:

-- [PATCH] Introduce GIT_TEMPLATE_DIR

Instead of passing --template explicitely to init-db and clone, you can just set the environment variable GIT_TEMPLATE_DIR.

Also make use of it in the tests, to make sure that the templates are copied.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 builtin-init-db.c |    7 +++++--
 t/test-lib.sh     |    3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index fa70baa..85cd4d9 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -124,8 +124,11 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
 	int template_len;
 	DIR *dir;
 
-	if (!template_dir)
-		template_dir = DEFAULT_GIT_TEMPLATE_DIR;
+	if (!template_dir) {
+		template_dir = getenv("GIT_TEMPLATE_DIR");
+		if (!template_dir)
+			template_dir = DEFAULT_GIT_TEMPLATE_DIR;
+	}
 	strcpy(template_path, template_dir);
 	template_len = strlen(template_path);
 	if (template_path[template_len-1] != '/') {
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ac7be76..f0f9cd6 100755
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -208,8 +208,9 @@ test_done () {
 # t/ subdirectory and are run in trash subdirectory.
 PATH=$(pwd)/..:$PATH
 GIT_EXEC_PATH=$(pwd)/..
+GIT_TEMPLATE_DIR=$(pwd)/../templates/blt
 HOME=$(pwd)/trash
-export PATH GIT_EXEC_PATH HOME
+export PATH GIT_EXEC_PATH GIT_TEMPLATE_DIR HOME
 
 GITPERLLIB=$(pwd)/../perl/blib/lib:$(pwd)/../perl/blib/arch/auto/Git
Previous: Junio C Hamano
Message 8 of 8 in “Adjust t5510 to put remotes in config”
  1. Adjust t5510 to put remotes in configJohannes Schindelin, Dec 17, 2006
  2. Johannes SchindelinDec 18, 2006
  3. Junio C HamanoDec 18, 2006
  4. Johannes SchindelinDec 18, 2006
  5. Johannes SchindelinDec 18, 2006
  6. Junio C HamanoDec 18, 2006
  7. Junio C HamanoDec 18, 2006
  8. Johannes SchindelinDec 19, 2006

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.