Re: GIT_CEILING_DIRECTORY
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 9, 2016, 17:29 UTC
- Message-ID
- <xmqqshzzimpo.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20160309110242.04d8d480@anarchist.wooz.org>
Barry Warsaw <barry@python.org> writes:
> I put my home directory under git (recently converted from bzr), but since I > have some subdirectories under $HOME that are not under git (and some that > are) I want to stop e.g. `git status` from traversing up into $HOME.
Let me understand the use case. You have $HOME/.git that governs everything under $HOME, but there are parts of $HOME/, such as $HOME/projects/*, that will never be controled by $HOME/.git?
Two obvious reactions are:
- hopefully $HOME/.gitignore covers these non-git parts by having entries like '/projects/'; this should not affect the behaviour of CEILING though.
- typing "git status" inside $HOME/projects/ does not make much sense in the first place.
I _think_ the "are we in a Git-managed working tree and if so, then where is the .git directory?" discovery works like this:
- Are we sitting inside a subdirectory of one of the CEILING
list elements? For the purpose of this determination,
directory 'foo' is not considered a subdirectory of 'foo'
itself. If we are, remember where the closest CEILING is.- Set the "directory we are checking" to the current directory.
- Iterate:
- Does the "directory we are checking" look like the root of a
working tree managed by Git? I.e. has ".git" directly in
it, etc. If so, we found the Git-managed working tree and
its ".git". Return. - Truncate one level from "directory we are checking",
i.e. chdir(..); - Are we at a filesystem boundary (unless an environment tells
us otherwise), or have we hit the closest CEILING we
determined earlier? We are not allowed to check if we are
in a Git-managed working tree at higher level than this
level. Return.- Otherwise, keep checking.
So setting $HOME/projects as one of the elements in the CEILING list would not stop us going up if you are actually at $HOME/projects, but we would stop if you started from $HOME/projects/python.
This somehow sounds a bit inconsistent to me, but I say "a bit inconsistent" because "Why do we give different answer to 'is $HOME/projects/python governed by $HOME/.git?' depending on where we start the discovery process?" is a non-argument (i.e. that is not the question CEILING is answering).
I have a feeling that we must have done that for a reason. It may be interesting to see what breaks in t1504 if the above logic is updated to stop when you start at a CEILING (unlike the current code where it stops only when you start below a CEILING).