git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* inconsistent detached worktree handling: several bugs
@ 2008-05-05 16:06 martin f krafft
  2008-05-07  8:15 ` Santi Béjar
  0 siblings, 1 reply; 5+ messages in thread
From: martin f krafft @ 2008-05-05 16:06 UTC (permalink / raw)
  To: git discussion list

[-- Attachment #1: Type: text/plain, Size: 3791 bytes --]

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

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inconsistent detached worktree handling: several bugs
  2008-05-05 16:06 inconsistent detached worktree handling: several bugs martin f krafft
@ 2008-05-07  8:15 ` Santi Béjar
  2008-05-07 18:06   ` martin f krafft
  0 siblings, 1 reply; 5+ messages in thread
From: Santi Béjar @ 2008-05-07  8:15 UTC (permalink / raw)
  To: martin f krafft; +Cc: git discussion list

On Mon, May 5, 2008 at 6:06 PM, martin f krafft <madduck@madduck.net> wrote:
> 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
>

I don't know if it resolves all the issues, but:

- If run outside of the working copy => equivalent to run it from the
top of the wc.
  (for the normal case it just fails)

- It is not recommended (supported?) to have the repository inside the
working directory
  (unless it is .git, of course)

Santi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inconsistent detached worktree handling: several bugs
  2008-05-07  8:15 ` Santi Béjar
@ 2008-05-07 18:06   ` martin f krafft
  2008-05-07 19:20     ` Santi Béjar
  0 siblings, 1 reply; 5+ messages in thread
From: martin f krafft @ 2008-05-07 18:06 UTC (permalink / raw)
  To: Santi Béjar, git discussion list

[-- Attachment #1: Type: text/plain, Size: 1197 bytes --]

also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.0915 +0100]:
> I don't know if it resolves all the issues, but:
> 
> - If run outside of the working copy => equivalent to run it from the
> top of the wc.
>   (for the normal case it just fails)

This is not what the output of git-status suggests:

lapse:~|master|.fgits/zsh.git% git status                                #1,801
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       modified:   ../../.zsh/zshrc/30_aliases
#
no changes added to commit (use "git add" and/or "git commit -a")

If, what you said were the case, it'd be .zsh/zshrc/30_aliases.
../.. is the setting of core.worktree.

> - It is not recommended (supported?) to have the repository inside
> the working directory (unless it is .git, of course)

Why not?

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"'oh, that was easy,' says Man, and for an encore goes on to prove
 that black is white and gets himself killed on the next zebra
 crossing."
            -- douglas adams, "the hitchhiker's guide to the galaxy"
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inconsistent detached worktree handling: several bugs
  2008-05-07 18:06   ` martin f krafft
@ 2008-05-07 19:20     ` Santi Béjar
  2008-05-07 19:32       ` martin f krafft
  0 siblings, 1 reply; 5+ messages in thread
From: Santi Béjar @ 2008-05-07 19:20 UTC (permalink / raw)
  To: martin f krafft; +Cc: git discussion list

On Wed, May 7, 2008 at 8:06 PM, martin f krafft <madduck@madduck.net> wrote:
> also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.0915 +0100]:
>
> > I don't know if it resolves all the issues, but:
>  >
>  > - If run outside of the working copy => equivalent to run it from the
>  > top of the wc.
>  >   (for the normal case it just fails)
>
>  This is not what the output of git-status suggests:
>
>  lapse:~|master|.fgits/zsh.git% git status                                #1,801
>
> # On branch master
>  # Changed but not updated:
>  #   (use "git add <file>..." to update what will be committed)
>  #
>  #       modified:   ../../.zsh/zshrc/30_aliases
>  #
>
> no changes added to commit (use "git add" and/or "git commit -a")
>
>  If, what you said were the case, it'd be .zsh/zshrc/30_aliases.
>  ../.. is the setting of core.worktree.
>

So it is run inside the worktree ( $workingdir/.fgits/zsh ) and the
repository is inside the worktree.

>
>  > - It is not recommended (supported?) to have the repository inside
>  > the working directory (unless it is .git, of course)
>
>  Why not?

I read it in this list but I don't find it now. Maybe because of the
special handling of .git does not apply to an arbitrary path.

Santi

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: inconsistent detached worktree handling: several bugs
  2008-05-07 19:20     ` Santi Béjar
@ 2008-05-07 19:32       ` martin f krafft
  0 siblings, 0 replies; 5+ messages in thread
From: martin f krafft @ 2008-05-07 19:32 UTC (permalink / raw)
  To: Santi Béjar, git discussion list

[-- Attachment #1: Type: text/plain, Size: 800 bytes --]

also sprach Santi Béjar <sbejar@gmail.com> [2008.05.07.2020 +0100]:
> So it is run inside the worktree ( $workingdir/.fgits/zsh ) and the
> repository is inside the worktree.

Doh, I should engage brain more often. :)

So this makes sense. What does not make sense is that git-diff
doesn't appear to work with any of this...

> I read it in this list but I don't find it now. Maybe because of
> the special handling of .git does not apply to an arbitrary path.

I think it actually does. But in my case, it's also .gitignored in
addition.

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
it is better to have loft and lost
than to never have loft at all.
                                                       -- groucho marx
 
spamtraps: madduck.bogus@madduck.net

[-- Attachment #2: Digital signature (see http://martin-krafft.net/gpg/) --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-07 19:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-05 16:06 inconsistent detached worktree handling: several bugs martin f krafft
2008-05-07  8:15 ` Santi Béjar
2008-05-07 18:06   ` martin f krafft
2008-05-07 19:20     ` Santi Béjar
2008-05-07 19:32       ` martin f krafft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).