git/list[1] front-page[2] threads[3] people[4] search[5] about
 

more concerns about '--git-dir'

From
PBPasha Bolokhov <pasha.bolokhov@gmail.com>
Date
May 23, 2014, 18:41 UTC
Message-ID
<CAKpPgvf_UfgtOkotPz+aF4=UqQTOmk0O8tXg4Cm3zjzFimUoHw@mail.gmail.com>
        Hi,
        Since at it, I have discovered a couple more minor things with
this rarely-used option. I'm however a bit wary of stepping on
somebody's nerve with this sort of picking things.. :)
        Nevertheless,
1) an apparent missing "normalize_path(git_dir)", when GIT_DIR is an
absolute path:
don't even need to name the repository anything different, but run this command:

$ cd ~/tmp/ $ git init $ git --git-dir=$HOME/tmp/../tmp/./././.git --work-tree=$HOME/tmp/../tmp/ status

You won't notice anything different in the output of course, but the
environment will be odd:
    GIT_DIR=../tmp/./././.git
    GIT_WORK_TREE=$HOME/tmp
Notice how the work-tree has been normalized and git-dir hasn't. It's
kinda hard to imagine when this can lead to an error, but never know.
Would there be objections to fixing this?
2) "git --git-dir=meta status" complains:

$ git --git-dir=meta init $ git --git-dir=meta status

yells that work-tree isn't setup and denies to run. I'm sure most people are aware of this. Yet, the "git-config" man page says that if --git-dir or GIT_DIR is given then work-tree is assumed to be the current directory. The difference with the actual behaviour is explained by the fact that when the repository is not named anything that ends with ".git" then it is considered a bare repository (if no --work-tree is given), and the work-tree doesn't get setup and thus the complaint. It maybe a safety precaution, so that Git doesn't assume that it's at the top of work-tree while it may be actually somewhere in the middle. But how is it different if the user runs "git --git-dir=/opt/sparc/src/.git add sccs.c" while still sitting in the middle of the tree? I can't judge myself which behaviour would be right here, and ask for an opinion

    thanks
Pasha
Next: Junio C Hamano
Message 1 of 3 in “more concerns about '--git-dir'”
  1. Pasha BolokhovMay 23, 2014
  2. Junio C HamanoMay 23, 2014
  3. Pasha BolokhovMay 23, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.