{"thread":{"id":"41648","subject":"GIT_CEILING_DIRECTORY","startedAt":"2016-03-09T16:02:42Z","lastAt":"2016-03-09T17:57:04Z","messageCount":3,"participants":["Barry Warsaw","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"280421","messageId":"20160309110242.04d8d480@anarchist.wooz.org","threadId":"41648","inReplyTo":null,"subject":"GIT_CEILING_DIRECTORY","fromName":"Barry Warsaw","fromEmail":"barry@python.org","sentAt":"2016-03-09T16:02:42Z","receivedAt":"2016-03-09T16:02:42Z","isPatch":false,"sender":{"key":"barry@python.org","avatar":"https://gravatar.com/avatar/c1f9952e8b0ee2ae199ba65f58cc2d3e0b71f3aa1006cadbee182ef74425d88b?d=mp&s=160"},"body":"I put my home directory under git (recently converted from bzr), but since I\nhave some subdirectories under $HOME that are not under git (and some that\nare) I want to stop e.g. `git status` from traversing up into $HOME.  For\nexample, I have a ~/projects directory with lots of subdirectories so when I'm\nin e.g. my CPython Mercurial checkout (~/projects/python), I don't want git to\ngo higher than ~/projects\n\nGIT_CEILING_DIRECTORIES seems like exactly the thing I want, so I set it to\n::$HOME/projects and this works great... unless I'm actually in ~/projects in\nwhich case `git status` shows me the status of the $HOME repository.\n\nI tried setting this to just $HOME, but that has the undesired side-effect of\nblocking $HOME status when I'm in a subdirectory that *is* part of the base\nrepo, e.g. ~/env.  IOW, with GIT_CEILING_DIRECTORIES=$HOME and I cd into\n~/env, I don't get any status.\n\nSo I'm wondering whether this should be considered a bug in git, or if there's\nsome other way to handle this corner case, or whether it's working as intended\nand I just have to live with it.\n\nCheers,\n-Barry\n"},{"id":"280422","messageId":"xmqqshzzimpo.fsf@gitster.mtv.corp.google.com","threadId":"41648","inReplyTo":"20160309110242.04d8d480@anarchist.wooz.org","subject":"Re: GIT_CEILING_DIRECTORY","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-09T17:29:39Z","receivedAt":"2016-03-09T17:29:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Barry Warsaw <barry@python.org> writes:\n\n> I put my home directory under git (recently converted from bzr), but since I\n> have some subdirectories under $HOME that are not under git (and some that\n> are) I want to stop e.g. `git status` from traversing up into $HOME.\n\nLet me understand the use case.  You have $HOME/.git that governs\neverything under $HOME, but there are parts of $HOME/, such as\n$HOME/projects/*, that will never be controled by $HOME/.git?\n\nTwo obvious reactions are:\n\n - hopefully $HOME/.gitignore covers these non-git parts by having\n   entries like '/projects/'; this should not affect the behaviour\n   of CEILING though.\n\n - typing \"git status\" inside $HOME/projects/ does not make much\n   sense in the first place.\n\nI _think_ the \"are we in a Git-managed working tree and if so, then\nwhere is the .git directory?\" discovery works like this:\n\n    - Are we sitting inside a subdirectory of one of the CEILING\n      list elements?  For the purpose of this determination,\n      directory 'foo' is not considered a subdirectory of 'foo'\n      itself.  If we are, remember where the closest CEILING is.\n\n    - Set the \"directory we are checking\" to the current directory.\n\n    - Iterate:\n\n      - Does the \"directory we are checking\" look like the root of a\n        working tree managed by Git?  I.e. has \".git\" directly in\n        it, etc.  If so, we found the Git-managed working tree and\n        its \".git\".  Return.\n\n      - Truncate one level from \"directory we are checking\",\n        i.e. chdir(..);\n\n      - Are we at a filesystem boundary (unless an environment tells\n        us otherwise), or have we hit the closest CEILING we\n        determined earlier?  We are not allowed to check if we are\n        in a Git-managed working tree at higher level than this\n        level.  Return.\n\n      - Otherwise, keep checking.\n\nSo setting $HOME/projects as one of the elements in the CEILING list\nwould not stop us going up if you are actually at $HOME/projects,\nbut we would stop if you started from $HOME/projects/python.\n\nThis somehow sounds a bit inconsistent to me, but I say \"a bit\ninconsistent\" because \"Why do we give different answer to 'is\n$HOME/projects/python governed by $HOME/.git?' depending on where we\nstart the discovery process?\" is a non-argument (i.e. that is not\nthe question CEILING is answering).\n\nI have a feeling that we must have done that for a reason.  It may\nbe interesting to see what breaks in t1504 if the above logic is\nupdated to stop when you start at a CEILING (unlike the current code\nwhere it stops only when you start below a CEILING).\n"},{"id":"280473","messageId":"20160309125704.162be49c@subdivisions.wooz.org","threadId":"41648","inReplyTo":"xmqqshzzimpo.fsf@gitster.mtv.corp.google.com","subject":"Re: GIT_CEILING_DIRECTORY","fromName":"Barry Warsaw","fromEmail":"barry@python.org","sentAt":"2016-03-09T17:57:04Z","receivedAt":"2016-03-09T17:57:04Z","isPatch":false,"sender":{"key":"barry@python.org","avatar":"https://gravatar.com/avatar/c1f9952e8b0ee2ae199ba65f58cc2d3e0b71f3aa1006cadbee182ef74425d88b?d=mp&s=160"},"body":"On Mar 09, 2016, at 09:29 AM, Junio C Hamano wrote:\n\n>Let me understand the use case.  You have $HOME/.git that governs\n>everything under $HOME, but there are parts of $HOME/, such as\n>$HOME/projects/*, that will never be controled by $HOME/.git?\n\nCorrect.\n\n>Two obvious reactions are:\n>\n> - hopefully $HOME/.gitignore covers these non-git parts by having\n>   entries like '/projects/'; this should not affect the behaviour\n>   of CEILING though.\n\nCorrect.  In this case, $HOME/.gitignore has `projects` so `git status`\netc. in $HOME does the right thing.\n\n> - typing \"git status\" inside $HOME/projects/ does not make much\n>   sense in the first place.\n\nTrue, and normally I wouldn't do this explicitly, but it comes up because I\nhave a bash prompt that shows me the status of the current directory\n($GIT_PS_*) so even when I just cd to ~/projects I see status for $HOME.\n\n>I _think_ the \"are we in a Git-managed working tree and if so, then\n>where is the .git directory?\" discovery works like this:\n[...]\n\n>So setting $HOME/projects as one of the elements in the CEILING list\n>would not stop us going up if you are actually at $HOME/projects,\n>but we would stop if you started from $HOME/projects/python.\n\nAnd indeed, that works great.\n\n>This somehow sounds a bit inconsistent to me, but I say \"a bit\n>inconsistent\" because \"Why do we give different answer to 'is\n>$HOME/projects/python governed by $HOME/.git?' depending on where we\n>start the discovery process?\" is a non-argument (i.e. that is not\n>the question CEILING is answering).\n>\n>I have a feeling that we must have done that for a reason.  It may\n>be interesting to see what breaks in t1504 if the above logic is\n>updated to stop when you start at a CEILING (unlike the current code\n>where it stops only when you start below a CEILING).\n\nThat would be interesting; it seems like it would solve my use case.\n\nCheers,\n-Barry\n"}]}