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

[PATCH] Fix initialization of a bare repository

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Aug 15, 2007, 16:25 UTC
Message-ID
<Pine.LNX.4.64.0708151821260.19496@wbgn129.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7v643hrnh1.fsf@gitster.siamese.dyndns.org>

The recent work-tree cleanup broke it; core.bare was set to false erroneously when calling "git --bare init". Coincidentally, this fixes "git clone --bare", too.

Noticed by Junio Hamano.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Wed, 15 Aug 2007, Junio C Hamano wrote:
	> It appears that with 1.5.3-rc5
	> 
	> 	$ git clone --bare $origin_url target.git
	> 
	> does not set "core.bare = true" in target.git/config.  We used
	> to, at least with 1.5.2.2.  I am strongly suspecting that this
	> is another fallout from the worktree series.
	Sorry.  Yes, this is another fallout.
	Maybe this is not enough, though.  Maybe we need to check if the 
	GIT_DIR=. too, since 7efeb8f0 would set the work tree to ".", too.
	But maybe this would merit a separate fix in set_work_tree(), like
		if (!strcmp(getenv(GIT_DIR_ENVIRONMENT), ".")) {
			inside_work_tree = 0;
			return NULL;
		}
	Hmm?
 builtin-init-db.c |   13 ++++++++-----
 git.c             |    1 +
 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 75fb227..2e45a7e 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -302,11 +302,14 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
 			usage(init_db_usage);
 	}
 
-	git_work_tree_cfg = xcalloc(PATH_MAX, 1);
-	if (!getcwd(git_work_tree_cfg, PATH_MAX))
-		die ("Cannot access current working directory.");
-	if (access(get_git_work_tree(), X_OK))
-		die ("Cannot access work tree '%s'", get_git_work_tree());
+	if (!is_bare_repository_cfg) {
+		git_work_tree_cfg = xcalloc(PATH_MAX, 1);
+		if (!getcwd(git_work_tree_cfg, PATH_MAX))
+			die ("Cannot access current working directory.");
+		if (access(get_git_work_tree(), X_OK))
+			die ("Cannot access work tree '%s'",
+					get_git_work_tree());
+	}
 
 	/*
 	 * Set up the default .git directory contents
diff --git a/git.c b/git.c
index 1bf2744..f0062a0 100644
--- a/git.c
+++ b/git.c
@@ -100,6 +100,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
 		} else if (!strcmp(cmd, "--bare")) {
 			static char git_dir[PATH_MAX+1];
 			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
+			is_bare_repository_cfg = 1;
 		} else if (!strcmp(cmd, "-2") ||
 				!strcmp(cmd, "--redirect-stderr")) {
 			if (dup2(1, 2) < 0)
-- 
1.5.1.rc1.4887.ga4a43-dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 8 in “git clone regression”
  1. Junio C HamanoAug 15, 2007
  2. Fix initialization of a bare repositoryJohannes Schindelin, Aug 15, 2007
  3. Junio C HamanoAug 15, 2007
  4. Junio C HamanoAug 15, 2007
  5. Junio C HamanoAug 15, 2007
  6. Johannes SchindelinAug 17, 2007
  7. Fix initialization of a bare repositoryJunio C Hamano, Aug 27, 2007
  8. Johannes SchindelinAug 27, 2007

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.