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

bug: setting GIT_DIR to $(git rev-parse --git-dir) changes behavior

From
MNMartin Nicolay <m.nicolay@osm-ag.de>
Date
Feb 25, 2021, 14:54 UTC
Message-ID
<alpine.LSU.2.20.2102251549330.20742@cpza.bfz-tzou.qr>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)

$ env | grep GIT $ git --version git version 2.30.1 $ git init t Initialized empty Git repository in /tmp/t/.git/ $ mkdir t/foo $ cd t/foo $ git rev-parse --show-toplevel /tmp/t $ GIT_DIR=$(git rev-parse --git-dir) git rev-parse --show-toplevel /tmp/t/foo $ git rev-parse --git-dir /tmp/t/.git

What did you expect to happen? (Expected behavior)
"git rev-parse --show-toplevel" should be the same in both invocation.
What happened instead? (Actual behavior)
"git rev-parse --show-toplevel" shows the current working directory if GIT_DIR is set.
What's different between what you expected and what actually happened?
Setting GIT_DIR to $(git rev-parse --git-dir) should not change anything.
Anything else you want to add:

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.30.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.3.18-22-default #1 SMP Wed Jun 3 12:16:43 UTC 2020 (720aeba) x86_64 compiler info: gnuc: 9.1 libc info: glibc: 2.26 $SHELL (typically, interactive shell): /opt/local/bin/bash

[Enabled Hooks]
Next: Junio C Hamano
Message 1 of 2 in “bug: setting GIT_DIR to $(git rev-parse --git-dir) changes behavior”
  1. Martin NicolayFeb 25, 2021
  2. Junio C HamanoFeb 25, 2021

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.