{"thread":{"id":"13387","subject":"inconsistent detached worktree handling: several bugs","startedAt":"2008-05-05T16:06:43Z","lastAt":"2008-05-07T19:32:39Z","messageCount":5,"participants":["martin f krafft","Santi Béjar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76134","messageId":"20080505160643.GA28318@lapse.madduck.net","threadId":"13387","inReplyTo":null,"subject":"inconsistent detached worktree handling: several bugs","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2008-05-05T16:06:43Z","receivedAt":"2008-05-05T16:06:43Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"I am playing around with detached worktrees and have identified\na number of bugs in the path handling. Specifically, it seems that\nwhile git-status and git-add/git-rm are consistent with respect to\neach other, they expose different behaviour in different scenarios.\ngit-diff, on the other hand, seems broken with respect to worktree\nhandling.\n\nLet me run you through what I did, bugs are\nidentified with ###BUG. Output is prefixed with #, which should make\nit easier to cut-n-paste to reproduce\n\n\n\nNote how $GIT_DIR is set for the first part of this exercise:\n\nmkdir worktree\nGIT_DIR=repo.git; export GIT_DIR\ngit --bare init\n# Initialized empty Git repository in repo.git/\ngit config core.bare false\ngit config core.worktree ../worktree\n\necho This is just a file called foo > worktree/foo\n\ngit add worktree/foo\n# fatal: pathspec 'worktree/foo' did not match any files\n###BUG: git should be able to factor out the common path prefix\n\nls foo\n# ls: cannot access foo: No such file or directory\ngit add foo      # very confusing, but works\n\ngit commit -m'initial checkin'\n# Created initial commit 2f2cdf3: initial checkin\n#  1 files changed, 1 insertions(+), 0 deletions(-)\n#  create mode 100644 foo\n\ngit status\n##  On branch master\n# nothing to commit (working directory clean)\n\ngit diff\n# diff --git a/foo b/foo\n# deleted file mode 100644\n# index 27b451e..0000000\n# --- a/foo\n# +++ /dev/null\n# @@ -1 +0,0 @@\n# -This is just a file called foo\n###BUG: git-diff doesn't seem to honour worktree and thinks the file\n###was deleted\n\ngit diff -- worktree/foo\n###BUG: no output, even though path was given\n\necho Another line >> worktree/foo\ngit status\n# # On branch master\n# # Changed but not updated:\n# #   (use \"git add <file>...\" to update what will be committed)\n# #\n# #       modified:   foo\n# #\n# no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\ngit diff -- worktree/foo\n###BUG: no output, even though path was given\n\ngit add foo\n# diff --git a/foo b/foo\n# deleted file mode 100644\n# index 76404d8..0000000\n# --- a/foo\n# +++ /dev/null\n# @@ -1,2 +0,0 @@\n# -This is just a file called foo\n# -Another line\n\ngit diff --cached\n# diff --git a/foo b/foo\n# index 27b451e..76404d8 100644\n# --- a/foo\n# +++ b/foo\n# @@ -1 +1,2 @@\n#  This is just a file called foo\n# +Another line\n\n\n\n-----------\nIf worktree is actually an ancestor of the Git repository *and* we\nchdir() into the repository, whether GIT_DIR is set or not, things\nlook different again:\n\nmv ../worktree/* ..\nrmdir ../worktree\ngit config core.worktree ..\ngit status\n# # On branch master\n# # Changed but not updated:\n# #   (use \"git add <file>...\" to update what will be committed)\n# #\n# #       modified:   ../foo\n# #\n# # Untracked files:\n# #   (use \"git add <file>...\" to include in what will be committed)\n# #\n# #       ./\n# no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\ngit diff\n# diff --git a/foo b/foo\n# deleted file mode 100644\n# index 76404d8..0000000\n# --- a/foo\n# +++ /dev/null\n# @@ -1,2 +0,0 @@\n# -This is just a file called foo\n# -Another line\n###BUG: again, git-diff can't find the local file\n\ngit add foo\n# fatal: pathspec 'repo.git/foo' did not match any files\n###BUG: inconsistent with above behaviour, but consistent with\n###git-status output\n\ngit add ../foo\ngit commit -m'another linee'\n# Created commit d016799: another linee\n#  1 files changed, 1 insertions(+), 0 deletions(-)\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"i might disagree with what you have to say,\n but I'll defend to the death your right to say it.\"\n                                                           -- voltaire\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"76257","messageId":"8aa486160805070115k676b03a6s59d3a74d48d44254@mail.gmail.com","threadId":"13387","inReplyTo":"20080505160643.GA28318@lapse.madduck.net","subject":"Re: inconsistent detached worktree handling: several bugs","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-07T08:15:09Z","receivedAt":"2008-05-07T08:15:09Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Mon, May 5, 2008 at 6:06 PM, martin f krafft <madduck@madduck.net> wrote:\n> I am playing around with detached worktrees and have identified\n>  a number of bugs in the path handling. Specifically, it seems that\n>  while git-status and git-add/git-rm are consistent with respect to\n>  each other, they expose different behaviour in different scenarios.\n>  git-diff, on the other hand, seems broken with respect to worktree\n>  handling.\n>\n>  Let me run you through what I did, bugs are\n>  identified with ###BUG. Output is prefixed with #, which should make\n>  it easier to cut-n-paste to reproduce\n>\n\nI don't know if it resolves all the issues, but:\n\n- If run outside of the working copy => equivalent to run it from the\ntop of the wc.\n  (for the normal case it just fails)\n\n- It is not recommended (supported?) to have the repository inside the\nworking directory\n  (unless it is .git, of course)\n\nSanti\n"},{"id":"76314","messageId":"20080507180637.GA2282@lapse.madduck.net","threadId":"13387","inReplyTo":"8aa486160805070115k676b03a6s59d3a74d48d44254@mail.gmail.com","subject":"Re: inconsistent detached worktree handling: several bugs","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2008-05-07T18:06:37Z","receivedAt":"2008-05-07T18:06:37Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.0915 +0100]:\n> I don't know if it resolves all the issues, but:\n> \n> - If run outside of the working copy => equivalent to run it from the\n> top of the wc.\n>   (for the normal case it just fails)\n\nThis is not what the output of git-status suggests:\n\nlapse:~|master|.fgits/zsh.git% git status                                #1,801\n# On branch master\n# Changed but not updated:\n#   (use \"git add <file>...\" to update what will be committed)\n#\n#       modified:   ../../.zsh/zshrc/30_aliases\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nIf, what you said were the case, it'd be .zsh/zshrc/30_aliases.\n../.. is the setting of core.worktree.\n\n> - It is not recommended (supported?) to have the repository inside\n> the working directory (unless it is .git, of course)\n\nWhy not?\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"'oh, that was easy,' says Man, and for an encore goes on to prove\n that black is white and gets himself killed on the next zebra\n crossing.\"\n            -- douglas adams, \"the hitchhiker's guide to the galaxy\"\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"76316","messageId":"8aa486160805071220v50026bf9ga5a8ae4314bffadc@mail.gmail.com","threadId":"13387","inReplyTo":"20080507180637.GA2282@lapse.madduck.net","subject":"Re: inconsistent detached worktree handling: several bugs","fromName":"Santi Béjar","fromEmail":"sbejar@gmail.com","sentAt":"2008-05-07T19:20:42Z","receivedAt":"2008-05-07T19:20:42Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"On Wed, May 7, 2008 at 8:06 PM, martin f krafft <madduck@madduck.net> wrote:\n> also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.0915 +0100]:\n>\n> > I don't know if it resolves all the issues, but:\n>  >\n>  > - If run outside of the working copy => equivalent to run it from the\n>  > top of the wc.\n>  >   (for the normal case it just fails)\n>\n>  This is not what the output of git-status suggests:\n>\n>  lapse:~|master|.fgits/zsh.git% git status                                #1,801\n>\n> # On branch master\n>  # Changed but not updated:\n>  #   (use \"git add <file>...\" to update what will be committed)\n>  #\n>  #       modified:   ../../.zsh/zshrc/30_aliases\n>  #\n>\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n>  If, what you said were the case, it'd be .zsh/zshrc/30_aliases.\n>  ../.. is the setting of core.worktree.\n>\n\nSo it is run inside the worktree ( $workingdir/.fgits/zsh ) and the\nrepository is inside the worktree.\n\n>\n>  > - It is not recommended (supported?) to have the repository inside\n>  > the working directory (unless it is .git, of course)\n>\n>  Why not?\n\nI read it in this list but I don't find it now. Maybe because of the\nspecial handling of .git does not apply to an arbitrary path.\n\nSanti\n"},{"id":"76317","messageId":"20080507193239.GA5588@lapse.madduck.net","threadId":"13387","inReplyTo":"8aa486160805071220v50026bf9ga5a8ae4314bffadc@mail.gmail.com","subject":"Re: inconsistent detached worktree handling: several bugs","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2008-05-07T19:32:39Z","receivedAt":"2008-05-07T19:32:39Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.2020 +0100]:\n> So it is run inside the worktree ( $workingdir/.fgits/zsh ) and the\n> repository is inside the worktree.\n\nDoh, I should engage brain more often. :)\n\nSo this makes sense. What does not make sense is that git-diff\ndoesn't appear to work with any of this...\n\n> I read it in this list but I don't find it now. Maybe because of\n> the special handling of .git does not apply to an arbitrary path.\n\nI think it actually does. But in my case, it's also .gitignored in\naddition.\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \nit is better to have loft and lost\nthan to never have loft at all.\n                                                       -- groucho marx\n \nspamtraps: madduck.bogus@madduck.net\n"}]}