{"thread":{"id":"14647","subject":"Moving .git around","startedAt":"2008-07-24T01:32:02Z","lastAt":"2008-08-03T18:51:29Z","messageCount":4,"participants":["Geoff Russell","Nguyen Thai Ngoc Duy","Jan Hudec"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84660","messageId":"93c3eada0807231832o6b7689c4j2913253d7ced62ba@mail.gmail.com","threadId":"14647","inReplyTo":null,"subject":"Moving .git around","fromName":"Geoff Russell","fromEmail":"geoffrey.russell@gmail.com","sentAt":"2008-07-24T01:32:02Z","receivedAt":"2008-07-24T01:32:02Z","isPatch":false,"sender":{"key":"geoffrey.russell@gmail.com","avatar":"https://gravatar.com/avatar/c30f497ccfa6bf06d86f30bd2ba092a2dd124c61c6bc902f7cb5c3f6486947de?d=mp&s=160"},"body":"For reasons which would take a while to explain, I'm building a repository\nin a directory  using \"--git-dir=xxxx/.git --work-tree=.\" and\nthen doing an \"mv  xxxx/.git ./.git\"  and then trying to work with\nthat repository  --- but can't\n\nBelow is a sample script. The last line (git add) fails with\n\nfatal: unable to create\n'/usr/local/AusTop/AuPrograms/AuServer/testgit/aaa/bbb/.git/index.lock':\nNo such file or directory\n\ngit doesn't seem to realise that there is a .git back up the tree.\n\nI'm using 1.5.5.1\n\nCheers,\nGeoff Russell\n\n------------------------ sample script\n#!/bin/sh\nif [ -d \"testgit\" ] ; then\n    echo \"remove testgit\"\n    /bin/rm -rf testgit\nfi\nmkdir testgit && echo yyyy >testgit/sample.sh && cd testgit\nmkdir aaa && mkdir aaa/bbb\necho xxxx > aaa/bbb/sample2.sh\nmkdir xxx\ngit --git-dir=xxx/.git --work-tree=. init\ngit --git-dir=xxx/.git --work-tree=. add *.sh\ngit --git-dir=xxx/.git --work-tree=. commit  -m demo\nmv xxx/.git .\ncd aaa/bbb\ngit add sample2.sh\n"},{"id":"84664","messageId":"fcaeb9bf0807231912t6f20d508va1381f324a8981aa@mail.gmail.com","threadId":"14647","inReplyTo":"93c3eada0807231832o6b7689c4j2913253d7ced62ba@mail.gmail.com","subject":"Re: Moving .git around","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2008-07-24T02:12:19Z","receivedAt":"2008-07-24T02:12:19Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 7/24/08, Geoff Russell <geoffrey.russell@gmail.com> wrote:\n> For reasons which would take a while to explain, I'm building a repository\n>  in a directory  using \"--git-dir=xxxx/.git --work-tree=.\" and\n>  then doing an \"mv  xxxx/.git ./.git\"  and then trying to work with\n>  that repository  --- but can't\n>\n>  Below is a sample script. The last line (git add) fails with\n>\n>  fatal: unable to create\n>  '/usr/local/AusTop/AuPrograms/AuServer/testgit/aaa/bbb/.git/index.lock':\n>  No such file or directory\n>\n>  git doesn't seem to realise that there is a .git back up the tree.\n\nIt's because when you did git --work-tree=. init, worktree is stored\nin .git/config. The code that chdir() in setup_git_directory()\nprobably forgot to chdir() back to toplevel worktree. Workaround could\nbe just remove core.worktree in .git/config.\n\n>  I'm using 1.5.5.1\n>\n>  Cheers,\n>  Geoff Russell\n>\n>  ------------------------ sample script\n>  #!/bin/sh\n>  if [ -d \"testgit\" ] ; then\n>     echo \"remove testgit\"\n>     /bin/rm -rf testgit\n>  fi\n>  mkdir testgit && echo yyyy >testgit/sample.sh && cd testgit\n>  mkdir aaa && mkdir aaa/bbb\n>  echo xxxx > aaa/bbb/sample2.sh\n>  mkdir xxx\n>  git --git-dir=xxx/.git --work-tree=. init\n>  git --git-dir=xxx/.git --work-tree=. add *.sh\n>  git --git-dir=xxx/.git --work-tree=. commit  -m demo\n>  mv xxx/.git .\n>  cd aaa/bbb\n>  git add sample2.sh\n>\n> --\n>  To unsubscribe from this list: send the line \"unsubscribe git\" in\n>  the body of a message to majordomo@vger.kernel.org\n>  More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n-- \nDuy\n"},{"id":"84665","messageId":"93c3eada0807231936ib103824u9204f1109119e1c2@mail.gmail.com","threadId":"14647","inReplyTo":"fcaeb9bf0807231912t6f20d508va1381f324a8981aa@mail.gmail.com","subject":"Re: Moving .git around","fromName":"Geoff Russell","fromEmail":"geoffrey.russell@gmail.com","sentAt":"2008-07-24T02:36:28Z","receivedAt":"2008-07-24T02:36:28Z","isPatch":false,"sender":{"key":"geoffrey.russell@gmail.com","avatar":"https://gravatar.com/avatar/c30f497ccfa6bf06d86f30bd2ba092a2dd124c61c6bc902f7cb5c3f6486947de?d=mp&s=160"},"body":"On Thu, Jul 24, 2008 at 11:42 AM, Nguyen Thai Ngoc Duy\n<pclouds@gmail.com> wrote:\n> On 7/24/08, Geoff Russell <geoffrey.russell@gmail.com> wrote:\n>> For reasons which would take a while to explain, I'm building a repository\n>>  in a directory  using \"--git-dir=xxxx/.git --work-tree=.\" and\n>>  then doing an \"mv  xxxx/.git ./.git\"  and then trying to work with\n>>  that repository  --- but can't\n>>\n>>  Below is a sample script. The last line (git add) fails with\n>>\n>>  fatal: unable to create\n>>  '/usr/local/AusTop/AuPrograms/AuServer/testgit/aaa/bbb/.git/index.lock':\n>>  No such file or directory\n>>\n>>  git doesn't seem to realise that there is a .git back up the tree.\n>\n> It's because when you did git --work-tree=. init, worktree is stored\n> in .git/config. The code that chdir() in setup_git_directory()\n> probably forgot to chdir() back to toplevel worktree. Workaround could\n> be just remove core.worktree in .git/config.\n\nMany thanks, the work-around works. I'm not sure if this is a bug or\na feature, but I'm happy either way.\n\nCheers,\nGeoff Russell\n\n>\n>>  I'm using 1.5.5.1\n>>\n>>  Cheers,\n>>  Geoff Russell\n>>\n>>  ------------------------ sample script\n>>  #!/bin/sh\n>>  if [ -d \"testgit\" ] ; then\n>>     echo \"remove testgit\"\n>>     /bin/rm -rf testgit\n>>  fi\n>>  mkdir testgit && echo yyyy >testgit/sample.sh && cd testgit\n>>  mkdir aaa && mkdir aaa/bbb\n>>  echo xxxx > aaa/bbb/sample2.sh\n>>  mkdir xxx\n>>  git --git-dir=xxx/.git --work-tree=. init\n>>  git --git-dir=xxx/.git --work-tree=. add *.sh\n>>  git --git-dir=xxx/.git --work-tree=. commit  -m demo\n>>  mv xxx/.git .\n>>  cd aaa/bbb\n>>  git add sample2.sh\n>>\n>> --\n>>  To unsubscribe from this list: send the line \"unsubscribe git\" in\n>>  the body of a message to majordomo@vger.kernel.org\n>>  More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>>\n>\n>\n> --\n> Duy\n>\n\n\n\n-- \n6 Fifth Ave,\nSt Morris, S.A. 5068\nAustralia\nPh: 041 8805 184 / 08 8332 5069\n"},{"id":"86092","messageId":"20080803185129.GB3482@efreet.light.src","threadId":"14647","inReplyTo":"93c3eada0807231936ib103824u9204f1109119e1c2@mail.gmail.com","subject":"Re: Moving .git around","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2008-08-03T18:51:29Z","receivedAt":"2008-08-03T18:51:29Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Thu, Jul 24, 2008 at 12:06:28 +0930, Geoff Russell wrote:\n> On Thu, Jul 24, 2008 at 11:42 AM, Nguyen Thai Ngoc Duy\n> <pclouds@gmail.com> wrote:\n> > On 7/24/08, Geoff Russell <geoffrey.russell@gmail.com> wrote:\n> >> For reasons which would take a while to explain, I'm building a repository\n> >>  in a directory  using \"--git-dir=xxxx/.git --work-tree=.\" and\n> >>  then doing an \"mv  xxxx/.git ./.git\"  and then trying to work with\n> >>  that repository  --- but can't\n> >>\n> >>  Below is a sample script. The last line (git add) fails with\n> >>\n> >>  fatal: unable to create\n> >>  '/usr/local/AusTop/AuPrograms/AuServer/testgit/aaa/bbb/.git/index.lock':\n> >>  No such file or directory\n> >>\n> >>  git doesn't seem to realise that there is a .git back up the tree.\n> >\n> > It's because when you did git --work-tree=. init, worktree is stored\n> > in .git/config. The code that chdir() in setup_git_directory()\n> > probably forgot to chdir() back to toplevel worktree. Workaround could\n> > be just remove core.worktree in .git/config.\n> \n> Many thanks, the work-around works. I'm not sure if this is a bug or\n> a feature, but I'm happy either way.\n\nThat depends on what the value of core.worktree is:\n - If it is '.', than I think it should be considered a bug in git init,\n   because that value is just plain nonsense.\n - If it is '..', than it's a user error and the right thing is to just\n   remove it when you relocate the .git directory.\n - If it was '/usr/local/AusTop/AuPrograms/AuServer/testgit/' than it would\n   have worked, so it's not that.\n\nBest regards,\nJan\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"}]}