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

[PATCH] [RED] git-init: Cannot setup bare repository

From
Petr Baudis <pasky@suse.cz>
Date
Aug 26, 2007, 20:45 UTC
Message-ID
<20070826204531.11592.36481.stgit@rover>

git-init is totally broken wrt. setting up bare repository - it thinks no repository is bare (maybe I could coerce it to think some repositories indeed are bare, but I have my doubts). This patch is more like a cry for help, not something to be applied, though it works as a crude workaround if you're hit by the same problem as me. Unfortunately it's hard to make sense of the tangled git_working_tree_cfg, work_tree, is_bare_tree_cfg etc. network of variables, so I don't have any clear idea about a proper fix nor the time to figure it out. :-(

Signed-off-by: Petr Baudis <pasky@suse.cz>
---
 builtin-init-db.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/builtin-init-db.c b/builtin-init-db.c
index 0d9b1e0..3718355 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -299,11 +299,15 @@ 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 (!strcmp(get_git_dir(), ".git")) {
+		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());
+	} else {
+		git_work_tree_cfg = NULL;
+	}
 
 	/*
 	 * Set up the default .git directory contents
Next: Johannes Schindelin
Message 1 of 4 in “[RED] git-init: Cannot setup bare repository”
  1. [RED] git-init: Cannot setup bare repositoryPetr Baudis, Aug 26, 2007
  2. Johannes SchindelinAug 27, 2007
  3. Petr BaudisAug 27, 2007
  4. Junio C HamanoAug 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.