Why use --git-dir?
Hello there
- I found that when executing SafeCmd,gitaly appends
--git-dirto the args
https://gitlab.com/gitlab-org/gitaly/-/blob/master/internal/git/command.go#L43
- But in this doc, it tell me use
git -C <path>if i just want to run git as if it was started in - I found that in a bare repo, the results obtained by using
git -c <path> shortlogandgit --git-dir shortlogare very different
cd
pathand rungit shortlogis same asgit -c <path> shortlog
- I don't know which one is right
Can someone help me resolve this question?
Thanks!
Reopen
I found another place, about command git rev-parse
If the HEAD in the repo points to a reference that does not exist,
--git-dir and -C will cause different output
This seems to be a git problem, but gitaly's processing may cause unexpected exceptions
https://gitlab.com/gitlab-org/gitaly/-/blob/master/internal/gitaly/service/ref/refs.go#L203
Edited by SURA
