On 01/15/13 00:25, Thomas Ferris Nicolaisen wrote:
On Tuesday, January 15, 2013 3:24:34 AM UTC+1, Tim Chase wrote:
However, when I try "git rev-parse --is-inside-work-tree" outside my
repo, I get
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
According to my reading of the docs/man-pages, I should get "false"
instead. Under what conditions should rev-parse return false?
As far as I understand, there are three related queries here:
1. is-inside-git-dir
2. is-inside-work-tree
3. is-bare-repository
They are used to discern whether you are inside the repo/.git dir, or in
the work-tree.
If you are in a bare repository, the first one will happen to always be
true, but if you want to know whether you're in a bare repository or not,
the third one is the one to use.
Ah, okay, so some further testing then shows the following results:
tim@bigbox:~/tmp/git_test$ for loc in '.' bare_repo/ nonbare_repo/
nonbare_repo/.git nonbare_repo/empty_dir/ ; do pushd $loc 2>&1
>/dev/null; echo In $loc; for test in is-inside-git-dir
is-inside-work-tree is-bare-repository; do echo -n ${test}: ; git
rev-parse --${test}; done; popd 2>&1 >/dev/null; echo
''; done
In .
is-inside-git-dir:fatal: Not a git repository (or any parent up to
mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
is-inside-work-tree:fatal: Not a git repository (or any parent up to
mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
is-bare-repository:fatal: Not a git repository (or any parent up to
mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not
set).
In bare_repo/
is-inside-git-dir:true
is-inside-work-tree:false
is-bare-repository:true
In nonbare_repo/
is-inside-git-dir:false
is-inside-work-tree:true
is-bare-repository:false
In nonbare_repo/.git
is-inside-git-dir:true
is-inside-work-tree:false
is-bare-repository:false
In nonbare_repo/empty_dir/
is-inside-git-dir:false
is-inside-work-tree:true
is-bare-repository:false
So EVERYTHING outside the repo fails. The --is-inside-work-tree
does return false (contrary to what I remember testing earlier)
inside .git, and in a bare repo. Okay, that makes sense. Thanks!
-tkc
--