Strange and broken behaviour when GIT_WORK_TREE is direct ancestor of GIT_DIR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello all,

I have run into very odd behaviour with git's --work-tree option/the
GIT_WORK_TREE environment variable.
I was experimenting with a workflow that involves targeted checkouts
of subdirectories in a repository,
commands of the form `git --work-tree=<dir> checkout @:<subdir> -- .`.
This worked fine, until I tried passing the parent directory
or any directory directly up the hierarchy (../, ../../, etc.) to
--work-tree, either as a relative or absolute path.
Almost all git commands behaved strangely or ceased to work at all.
I could not find any information in the git documentation or online
about this being a restriction in git, and given the
observed behaviour I believe it to be a bug, though I'm not sure if
it's something that should work or is something git should reject.

`git ls-tree` works as usual.
`git --work-tree=../empty-dir ls-tree` also works.
`git --work-tree=../nonexistent` also works.
`git --work-tree=../ ls-tree` prints nothing at all.

`git --work-tree=.. status` seems to behave mostly as it should
(reporting all files as having been deleted since the directory is
mostly empty),
but strangely reports the current directory (./) as an untracked file.
It correctly reports any other files in the parent directory as
untracked,
though it excludes the git repository itself from the list. It also
reported the paths of the files strangely,
prefixing them with ../ (or multiple ../ segments if the passed
--work-tree was several levels up).
This never happened with any other paths.

`git --work-tree=.. checkout <branch>` seems to write out the index
and working directory correctly, but while testing it would
sometimes update HEAD and sometimes not.

`git --work-tree=.. checkout [branch/treeish] -- <files>` completely
refused to work, always saying "pathspec did not match any files",
even for dot (.) and catch-all patterns.

This happens both with regular and bare repositories, and in all
repositories that I tested with.

I am using git 2.43.0 through the Arch Linux distribution.
My git configuration doesn't change any settings related to paths and
directories.

I apologize if this email is formatted suboptimally.
Thank you for your time.




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux