On Thu, Apr 22, 2021 at 6:59 AM SZEDER Gábor <szeder.dev@xxxxxxxxx> wrote: > > See the comment above the changed line: we don't want auto-detection > > to clobber the surrounding git repo. > > Indeed, but then this is not a faithful conversion of the original. > That 'echo' will write sane content to HEAD no matter what state the > repository is in. That 'symbolic-ref' command, however, won't, > because 'git --git-dir .git' turns off only repository discovery, but > not repository verification, and in case of a corrupt '.git/HEAD' it > will bail out. > > $ cd test > $ git init > Initialized empty Git repository in /home/szeder/src/git/test/.git/ > $ git commit --allow-empty -m initial > [master (root-commit) ec0df0b] initial > $ echo "foo bar baz" >.git/HEAD > $ git --git-dir .git symbolic-ref HEAD refs/heads/master > fatal: not a git repository: '.git' But then it's working as intended, no? It will not corrupt the surrounding repository. I see it as the test writer's job to clean up to the extent that git-symbolic-ref can reset to a sane state. We could reset back to a known state in a more drastic manner (extracting .git from a tar archive), but that could interfere with the test functions if they're not isolated from each other. -- Han-Wen Nienhuys - Google Munich I work 80%. Don't expect answers from me on Fridays. -- Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado