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

Re: [PATCH] t1020-subdirectory: test alias expansion in a subdirectory

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Nov 8, 2010, 10:20 UTC
Message-ID
<20101108102056.GA12366@do>
In-Reply-To
<627dc7921dc64a16063e77d542cf9edb22631ddd.1289205059.git.git@drmicha.warpmail.net>
On Mon, Nov 08, 2010 at 09:32:03AM +0100, Michael J Gruber wrote:
Show 7 quoted lines
> Add a test for alias expansion in a subdirectory of the worktree.
> 
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> 
> ---
>     65f3a9e (Remove all logic from get_git_work_tree(), 2010-11-01) breaks this test,
>     which is why I am adding it.
How about squashing this in?
--8<--
Subject: Allow set_git_work_tree() to be called more than once

Usually one of the setup functions is called once. However alias handling code needs to look ahead in $GIT_DIR/config for aliases. So set_git_work_tree() may be called twice: once when alias is searched, once when the actual command is run.

Loosen the condition and let it through. We can stricten it back when alias handling is fixed. ---

diff --git a/environment.c b/environment.c
index 6db00da..f0d0b07 100644
--- a/environment.c
+++ b/environment.c
@@ -128,8 +128,6 @@ const char *get_git_dir(void)
 	return git_dir;
 }
 
-static int git_work_tree_initialized;
-
 /*
  * Note.  This works only before you used a work tree.  This was added
  * primarily to support git-clone to work in a new repository it just
@@ -137,9 +135,7 @@ static int git_work_tree_initialized;
  */
 void set_git_work_tree(const char *new_work_tree)
 {
-	if (git_work_tree_initialized)
-		die("internal error: work tree has already been set");
-	git_work_tree_initialized = 1;
+	free(work_tree);
 	work_tree = xstrdup(make_absolute_path(new_work_tree));
 }
 
--8<--
-- 
Duy
Previous: Michael J GruberNext: Junio C Hamano
Message 2 of 5 in “t1020-subdirectory: test alias expansion in a subdirectory”
  1. t1020-subdirectory: test alias expansion in a subdirectoryMichael J Gruber, Nov 8, 2010
  2. Nguyen Thai Ngoc DuyNov 8, 2010
  3. Junio C HamanoNov 8, 2010
  4. Nguyen Thai Ngoc DuyNov 9, 2010
  5. t0001: test git init when run via an aliasNguyễn Thái Ngọc Duy, Nov 8, 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.