{"thread":{"id":"6357","subject":"1.5.0.rc1.g4494: Can't use a bare GIT_DIR to add","startedAt":"2007-01-12T15:45:22Z","lastAt":"2007-01-12T17:56:48Z","messageCount":3,"participants":["Horst H. von Brand","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"31562","messageId":"200701121545.l0CFjMC1017088@laptop13.inf.utfsm.cl","threadId":"6357","inReplyTo":null,"subject":"1.5.0.rc1.g4494: Can't use a bare GIT_DIR to add","fromName":"Horst H. von Brand","fromEmail":"vonbrand@inf.utfsm.cl","sentAt":"2007-01-12T15:45:22Z","receivedAt":"2007-01-12T15:45:22Z","isPatch":false,"sender":{"key":"vonbrand@inf.utfsm.cl","avatar":"https://avatars.githubusercontent.com/u/211384?v=4"},"body":"I tried this:\n  \n  mkdir xyz\n  cd xyz\n  git --git-dir=../xyz.git   \n     # Initialized empty Git repository in ../xyz.git/\n  echo Junk > file-a\n  git --git-dir=../xyz.git add .\n     # fatal: add cannot be used in a bare git directory\n\nI expected that \"GIT_DIR is bare, over there, stuff is here\" works the same\nas \"GIT_DIR is .git, right here among stuff\".\n-- \nDr. Horst H. von Brand                   User #22616 counter.li.org\nDepartamento de Informatica                    Fono: +56 32 2654431\nUniversidad Tecnica Federico Santa Maria             +56 32 2654239\nCasilla 110-V, Valparaiso, Chile               Fax:  +56 32 2797513\n"},{"id":"31564","messageId":"7v7ivsup3z.fsf@assigned-by-dhcp.cox.net","threadId":"6357","inReplyTo":"200701121545.l0CFjMC1017088@laptop13.inf.utfsm.cl","subject":"Re: 1.5.0.rc1.g4494: Can't use a bare GIT_DIR to add","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-12T17:33:20Z","receivedAt":"2007-01-12T17:33:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Horst H. von Brand\" <vonbrand@inf.utfsm.cl> writes:\n\n> I tried this:\n>   \n>   mkdir xyz\n>   cd xyz\n>   git --git-dir=../xyz.git   \n>      # Initialized empty Git repository in ../xyz.git/\n>   echo Junk > file-a\n>   git --git-dir=../xyz.git add .\n>      # fatal: add cannot be used in a bare git directory\n>\n> I expected that \"GIT_DIR is bare, over there, stuff is here\" works the same\n> as \"GIT_DIR is .git, right here among stuff\".\n> -- \n> Dr. Horst H. von Brand                   User #22616 counter.li.org\n> Departamento de Informatica                    Fono: +56 32 2654431\n> Universidad Tecnica Federico Santa Maria             +56 32 2654239\n> Casilla 110-V, Valparaiso, Chile               Fax:  +56 32 2797513\n"},{"id":"31567","messageId":"7vzm8ot9gf.fsf@assigned-by-dhcp.cox.net","threadId":"6357","inReplyTo":"200701121545.l0CFjMC1017088@laptop13.inf.utfsm.cl","subject":"Re: 1.5.0.rc1.g4494: Can't use a bare GIT_DIR to add","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-01-12T17:56:48Z","receivedAt":"2007-01-12T17:56:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Horst H. von Brand\" <vonbrand@inf.utfsm.cl> writes:\n\n> I tried this:\n>   \n>   mkdir xyz\n>   cd xyz\n>   git --git-dir=../xyz.git   \n>      # Initialized empty Git repository in ../xyz.git/\n>   echo Junk > file-a\n>   git --git-dir=../xyz.git add .\n>      # fatal: add cannot be used in a bare git directory\n>\n> I expected that \"GIT_DIR is bare, over there, stuff is here\" works the same\n> as \"GIT_DIR is .git, right here among stuff\".\n\nSheesh, why didn't you speak out earlier while the discussion\nwas on (I am not serious, git mailing list is still moving too\nfast for people to be always on top of)?\n\nNow, seriously.\n\nThe \"bare\" topic introduced \"is this repository bare?\" check,\nwhich can say only \"yes\" or \"no\" for any given GIT_DIR.  A\nheuristic is there but can be overriden with \"core.bare\"\nconfiguration.  We allow certain things we usually do not allow\nin a repository without working tree (e.g. updating the branch\npointed at with HEAD via \"git-fetch\"), and we forbid things that\nrequire a working tree in a bare repository (e.g. \"git-checkout\").\n\nThis \"your bare repository is my repository with worktree\nelsewhere\" was not something we considered during the \"bare\"\ndiscussion.  If we wanted to allow that, the check needs to say\n\"yes\", \"no\", or \"depends\", and we need to allow both kinds of\noperations in a repository marked as the third kind.\n\nYou said \"I tried\".  Is this something you do in real life?\nThis _is_ a regression, as we are checking something we did not\ncheck before and refusing to work in cases where we did.  But I\nam not sure if reverting to lift the safety (for that matter,\nintroducing the third \"depends\" alternative) is better than the\nlatest behaviour.\n\nFor one thing, you could (sometime before the \"git add .\" and do\nthis only once) do:\n\n\t$ ln -s ../xyz.git .git\n\nand that would make all the future git operation work without\nthe --git-dir parameter (or GIT_DIR environment) in xyz\ndirectory.  An added benefit is that it would even allow git\ncommand to work from a subdirectory of xyz (specifying GIT_DIR\nor --git-dir means you are bypassing the discovery for the top\nof the working tree, so you have to always be at the top).\n\nHmmmm.\n"}]}