All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] Wrong worktree path when using multiple worktree
@ 2015-11-03 16:58 Nicolas Morey-Chaisemartin
  2015-11-03 22:27 ` Mike Rappazzo
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Morey-Chaisemartin @ 2015-11-03 16:58 UTC (permalink / raw)
  To: git

Hi,

There seem to be an issue with the path computed for a worktree when multiple worktree were created (using git worktree)
In my Setup, I have 3 repos:
A/repo (main One)
A/repo-patches (worktree, using branch dev)
B/repo (worktree, using branch next)

I'm working in A/repo-patches an run:
$ git checkout next
fatal: 'next' is already checked out at 'A/repo-patches'

Which is partially true but not completely.
I looked a bit in the code and found that the issue comes from here (get_linked_worktree):
    if (!strbuf_strip_suffix(&worktree_path, "/.git")) {
        strbuf_reset(&worktree_path);
        strbuf_addstr(&worktree_path, absolute_path("."));
        strbuf_strip_suffix(&worktree_path, "/.");
    }
Because it wrongfully assumes that I am in the linked worktree.
I checked in the .git/worktree files and couldn't see anything that actually points to where the repo are setup.

Nicolas

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

* Re: [BUG] Wrong worktree path when using multiple worktree
  2015-11-03 16:58 [BUG] Wrong worktree path when using multiple worktree Nicolas Morey-Chaisemartin
@ 2015-11-03 22:27 ` Mike Rappazzo
  2015-11-04  2:23   ` Mike Rappazzo
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Rappazzo @ 2015-11-03 22:27 UTC (permalink / raw)
  To: Nicolas Morey-Chaisemartin; +Cc: Git List

On Tue, Nov 3, 2015 at 11:58 AM, Nicolas Morey-Chaisemartin
<nicolas@morey-chaisemartin.com> wrote:
> Hi,
>
> There seem to be an issue with the path computed for a worktree when multiple worktree were created (using git worktree)
> In my Setup, I have 3 repos:
> A/repo (main One)
> A/repo-patches (worktree, using branch dev)
> B/repo (worktree, using branch next)
>
> I'm working in A/repo-patches an run:
> $ git checkout next
> fatal: 'next' is already checked out at 'A/repo-patches'
>
> Which is partially true but not completely.
> I looked a bit in the code and found that the issue comes from here (get_linked_worktree):
>     if (!strbuf_strip_suffix(&worktree_path, "/.git")) {
>         strbuf_reset(&worktree_path);
>         strbuf_addstr(&worktree_path, absolute_path("."));
>         strbuf_strip_suffix(&worktree_path, "/.");
>     }
> Because it wrongfully assumes that I am in the linked worktree.
> I checked in the .git/worktree files and couldn't see anything that actually points to where the repo are setup.
>
> Nicolas

This is code that I worked on, but I am unable to reproduce it locally
just yet.  Before I dig too deep, could you report the contents of
"A/repo/.git/worktrees/repo-patches/gitdir" (or similar)?  There is
another issue reported[1] where the contents of the gitdir for a
linked worktree are overwritten in some cases.  A fix for this is
being worked on (see discussion).

In the mean time, I will continue to try and reproduce.

[1]: http://thread.gmane.org/gmane.comp.version-control.git/280307

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

* Re: [BUG] Wrong worktree path when using multiple worktree
  2015-11-03 22:27 ` Mike Rappazzo
@ 2015-11-04  2:23   ` Mike Rappazzo
  0 siblings, 0 replies; 3+ messages in thread
From: Mike Rappazzo @ 2015-11-04  2:23 UTC (permalink / raw)
  To: Nicolas Morey-Chaisemartin; +Cc: Git List

On Tue, Nov 3, 2015 at 5:27 PM, Mike Rappazzo <rappazzo@gmail.com> wrote:
> On Tue, Nov 3, 2015 at 11:58 AM, Nicolas Morey-Chaisemartin
> <nicolas@morey-chaisemartin.com> wrote:
>> Hi,
>>
>> There seem to be an issue with the path computed for a worktree when multiple worktree were created (using git worktree)
>> In my Setup, I have 3 repos:
>> A/repo (main One)
>> A/repo-patches (worktree, using branch dev)
>> B/repo (worktree, using branch next)
>>
>> I'm working in A/repo-patches an run:
>> $ git checkout next
>> fatal: 'next' is already checked out at 'A/repo-patches'
>>
>> Which is partially true but not completely.
>> I looked a bit in the code and found that the issue comes from here (get_linked_worktree):
>>     if (!strbuf_strip_suffix(&worktree_path, "/.git")) {
>>         strbuf_reset(&worktree_path);
>>         strbuf_addstr(&worktree_path, absolute_path("."));
>>         strbuf_strip_suffix(&worktree_path, "/.");
>>     }
>> Because it wrongfully assumes that I am in the linked worktree.
>> I checked in the .git/worktree files and couldn't see anything that actually points to where the repo are setup.
>>
>> Nicolas
>
> This is code that I worked on, but I am unable to reproduce it locally
> just yet.  Before I dig too deep, could you report the contents of
> "A/repo/.git/worktrees/repo-patches/gitdir" (or similar)?  There is
> another issue reported[1] where the contents of the gitdir for a
> linked worktree are overwritten in some cases.  A fix for this is
> being worked on (see discussion).
>
> In the mean time, I will continue to try and reproduce.
>
> [1]: http://thread.gmane.org/gmane.comp.version-control.git/280307

Followup:  I was able to reproduce the error when I tried to simulate
the aforementioned bug.  Here is a test which I added to t2027 (not
intended to publish):

+test_expect_success '"checkout" branch already checked out' '
+ git worktree add -b linked_1_br linked_1 master &&
+ git worktree add -b linked_2_br linked_2 master &&
+ echo ".git" > .git/worktrees/linked_2/gitdir &&
+ test_must_fail git -C linked_1 checkout linked_2_br
+'
+

Test run result:
--------------------
Preparing linked_1 (identifier linked_1)
HEAD is now at 2519212 init
Preparing linked_2 (identifier linked_2)
HEAD is now at 2519212 init
fatal: 'linked_2_br' is already checked out at
'/Users/mike/code/git-source/t/trash
directory.t2027-worktree-list/linked_1'

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

end of thread, other threads:[~2015-11-04  2:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-03 16:58 [BUG] Wrong worktree path when using multiple worktree Nicolas Morey-Chaisemartin
2015-11-03 22:27 ` Mike Rappazzo
2015-11-04  2:23   ` Mike Rappazzo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.