{"thread":{"id":"9662","subject":"[PATCH] [RED] git-init: Cannot setup bare repository","startedAt":"2007-08-26T20:45:31Z","lastAt":"2007-08-27T10:01:53Z","messageCount":4,"participants":["Petr Baudis","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"51602","messageId":"20070826204531.11592.36481.stgit@rover","threadId":"9662","inReplyTo":null,"subject":"[PATCH] [RED] git-init: Cannot setup bare repository","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-08-26T20:45:31Z","receivedAt":"2007-08-26T20:45:31Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"git-init is totally broken wrt. setting up bare repository - it thinks no\nrepository is bare (maybe I could coerce it to think some repositories\nindeed are bare, but I have my doubts). This patch is more like a cry for\nhelp, not something to be applied, though it works as a crude workaround if\nyou're hit by the same problem as me. Unfortunately it's hard to make sense\nof the tangled git_working_tree_cfg, work_tree, is_bare_tree_cfg etc.\nnetwork of variables, so I don't have any clear idea about a proper fix nor\nthe time to figure it out. :-(\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\n---\n\n builtin-init-db.c |   14 +++++++++-----\n 1 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin-init-db.c b/builtin-init-db.c\nindex 0d9b1e0..3718355 100644\n--- a/builtin-init-db.c\n+++ b/builtin-init-db.c\n@@ -299,11 +299,15 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)\n \t\t\tusage(init_db_usage);\n \t}\n \n-\tgit_work_tree_cfg = xcalloc(PATH_MAX, 1);\n-\tif (!getcwd(git_work_tree_cfg, PATH_MAX))\n-\t\tdie (\"Cannot access current working directory.\");\n-\tif (access(get_git_work_tree(), X_OK))\n-\t\tdie (\"Cannot access work tree '%s'\", get_git_work_tree());\n+\tif (!strcmp(get_git_dir(), \".git\")) {\n+\t\tgit_work_tree_cfg = xcalloc(PATH_MAX, 1);\n+\t\tif (!getcwd(git_work_tree_cfg, PATH_MAX))\n+\t\t\tdie (\"Cannot access current working directory.\");\n+\t\tif (access(get_git_work_tree(), X_OK))\n+\t\t\tdie (\"Cannot access work tree '%s'\", get_git_work_tree());\n+\t} else {\n+\t\tgit_work_tree_cfg = NULL;\n+\t}\n \n \t/*\n \t * Set up the default .git directory contents\n"},{"id":"51660","messageId":"Pine.LNX.4.64.0708270949590.28586@racer.site","threadId":"9662","inReplyTo":"20070826204531.11592.36481.stgit@rover","subject":"Re: [PATCH] [RED] git-init: Cannot setup bare repository","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-27T08:51:04Z","receivedAt":"2007-08-27T08:51:04Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 26 Aug 2007, Petr Baudis wrote:\n\n> git-init is totally broken wrt. setting up bare repository - it thinks \n> no repository is bare (maybe I could coerce it to think some \n> repositories indeed are bare, but I have my doubts).\n\nYou were too busy playing Go, probably, so you missed my patch which tried \nto fix this issue.  Alas, it broke more than it fixed, so it was just \nworked around for git-clone --bare.\n\nI'll have a more thorough go at it today.\n\nCiao,\nDscho\n"},{"id":"51672","messageId":"20070827095523.GQ1219@pasky.or.cz","threadId":"9662","inReplyTo":"Pine.LNX.4.64.0708270949590.28586@racer.site","subject":"Re: [PATCH] [RED] git-init: Cannot setup bare repository","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2007-08-27T09:55:23Z","receivedAt":"2007-08-27T09:55:23Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"  Hi,\n\nOn Mon, Aug 27, 2007 at 10:51:04AM CEST, Johannes Schindelin wrote:\n> On Sun, 26 Aug 2007, Petr Baudis wrote:\n> \n> > git-init is totally broken wrt. setting up bare repository - it thinks \n> > no repository is bare (maybe I could coerce it to think some \n> > repositories indeed are bare, but I have my doubts).\n> \n> You were too busy playing Go, probably, so you missed my patch which tried \n> to fix this issue.  Alas, it broke more than it fixed, so it was just \n> worked around for git-clone --bare.\n\n  AFAICS that patch is already applied as well; I tried to ask on IRC\nfor more fixes but seemed there is none and Junio almost threatened to\neven release 1.5.3 with this bug. ;-) Well, I just needed something that\nwould fix this on repo.or.cz which totally broke after upgrade to new\nGit version.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nEarly to rise and early to bed makes a male healthy and wealthy and dead.\n                -- James Thurber\n"},{"id":"51673","messageId":"7vtzqljnxq.fsf@gitster.siamese.dyndns.org","threadId":"9662","inReplyTo":"20070827095523.GQ1219@pasky.or.cz","subject":"Re: [PATCH] [RED] git-init: Cannot setup bare repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-27T10:01:53Z","receivedAt":"2007-08-27T10:01:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> On Mon, Aug 27, 2007 at 10:51:04AM CEST, Johannes Schindelin wrote:\n>> On Sun, 26 Aug 2007, Petr Baudis wrote:\n>> ...\n>> You were too busy playing Go, probably, so you missed my patch which tried \n>> to fix this issue.  Alas, it broke more than it fixed, so it was just \n>> worked around for git-clone --bare.\n>\n>   AFAICS that patch is already applied as well; I tried to ask on IRC\n> for more fixes but seemed there is none and Junio almost threatened to\n> even release 1.5.3 with this bug. ;-) Well, I just needed something that\n> would fix this on repo.or.cz which totally broke after upgrade to new\n> Git version.\n\nHeh, \"threaten\" is a good word.  Could you two help me with this\nissue?  I suspect you (and probably Shawn) have the most \"old\nfashioned\" scripts that rather rely on pre-work-tree behaviour\nand have better chance than others to catch unintended side\neffects like the current \"git --bare init\"  issues.\n"}]}