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

inconsistent detached worktree handling: several bugs

From
MKmartin f krafft <madduck@madduck.net>
Date
May 5, 2008, 16:06 UTC
Message-ID
<20080505160643.GA28318@lapse.madduck.net>

I am playing around with detached worktrees and have identified a number of bugs in the path handling. Specifically, it seems that while git-status and git-add/git-rm are consistent with respect to each other, they expose different behaviour in different scenarios. git-diff, on the other hand, seems broken with respect to worktree handling.

Let me run you through what I did, bugs are identified with ###BUG. Output is prefixed with #, which should make it easier to cut-n-paste to reproduce

Note how $GIT_DIR is set for the first part of this exercise:

mkdir worktree GIT_DIR=repo.git; export GIT_DIR git --bare init # Initialized empty Git repository in repo.git/ git config core.bare false git config core.worktree ../worktree

echo This is just a file called foo > worktree/foo

git add worktree/foo # fatal: pathspec 'worktree/foo' did not match any files ###BUG: git should be able to factor out the common path prefix

ls foo # ls: cannot access foo: No such file or directory git add foo # very confusing, but works

git commit -m'initial checkin' # Created initial commit 2f2cdf3: initial checkin # 1 files changed, 1 insertions(+), 0 deletions(-) # create mode 100644 foo

git status ## On branch master # nothing to commit (working directory clean)

git diff # diff --git a/foo b/foo # deleted file mode 100644 # index 27b451e..0000000 # --- a/foo # +++ /dev/null # @@ -1 +0,0 @@ # -This is just a file called foo ###BUG: git-diff doesn't seem to honour worktree and thinks the file ###was deleted

git diff -- worktree/foo ###BUG: no output, even though path was given

echo Another line >> worktree/foo git status # # On branch master # # Changed but not updated: # # (use "git add <file>..." to update what will be committed) # # # # modified: foo # # # no changes added to commit (use "git add" and/or "git commit -a")

git diff -- worktree/foo ###BUG: no output, even though path was given

git add foo # diff --git a/foo b/foo # deleted file mode 100644 # index 76404d8..0000000 # --- a/foo # +++ /dev/null # @@ -1,2 +0,0 @@ # -This is just a file called foo # -Another line

git diff --cached # diff --git a/foo b/foo # index 27b451e..76404d8 100644 # --- a/foo # +++ b/foo # @@ -1 +1,2 @@ # This is just a file called foo # +Another line

----------- If worktree is actually an ancestor of the Git repository *and* we chdir() into the repository, whether GIT_DIR is set or not, things look different again:

mv ../worktree/* .. rmdir ../worktree git config core.worktree .. git status # # On branch master # # Changed but not updated: # # (use "git add <file>..." to update what will be committed) # # # # modified: ../foo # # # # Untracked files: # # (use "git add <file>..." to include in what will be committed) # # # # ./ # no changes added to commit (use "git add" and/or "git commit -a")

git diff # diff --git a/foo b/foo # deleted file mode 100644 # index 76404d8..0000000 # --- a/foo # +++ /dev/null # @@ -1,2 +0,0 @@ # -This is just a file called foo # -Another line ###BUG: again, git-diff can't find the local file

git add foo # fatal: pathspec 'repo.git/foo' did not match any files ###BUG: inconsistent with above behaviour, but consistent with ###git-status output

git add ../foo git commit -m'another linee' # Created commit d016799: another linee # 1 files changed, 1 insertions(+), 0 deletions(-)

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"i might disagree with what you have to say,
 but I'll defend to the death your right to say it."
                                                           -- voltaire
 
spamtraps: madduck.bogus@madduck.net
Next: Santi Béjar
Message 1 of 5 in “inconsistent detached worktree handling: several bugs”
  1. martin f krafftMay 5, 2008
  2. Santi BéjarMay 7, 2008
  3. martin f krafftMay 7, 2008
  4. Santi BéjarMay 7, 2008
  5. martin f krafftMay 7, 2008

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.