git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Bug^Feature? fetch protects only current working tree branch
@ 2017-07-23 14:50 Andreas Heiduk
  2017-07-23 22:13 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Heiduk @ 2017-07-23 14:50 UTC (permalink / raw)
  To: Git Mailing List

A `git fetch . origin/master:master` protects the currently checked out 
branch (HEAD) unless the `-u/--update-head-ok` is supplied. This avoids a
mismatch between the index and HEAD. BUT branches which are HEADs in other
working trees do not get that care - their state is silently screwed up.

Is this intended behaviour or and just an oversight while implementing
`git worktree`?


Steps to reproduce

    # setup

    git clone -b master $SOMETHING xtemp
    cd xtemp
    git reset --hard HEAD~5 # pretend to be back some time
    git worktree add ../xtemp-wt1
    git worktree add ../xtemp-wt2

    # test

    git fetch . origin/master:master
    
        fatal: Refusing to fetch into current branch refs/heads/master  of non-bare repository
        fatal: The remote end hung up unexpectedly

    # OK, current working tree is protected, try another one:

    git fetch . origin/master:xtemp-wt1

        From .
           b4d1278..6e7b60d  origin/master -> xtemp-wt1

    cd ../xtemp-wt1
    git status

        # admire messed up working tree here

    # The protection is really "current working tree", not "first/main working tree"!

    git fetch . origin/master:master

        From .
           b4d1278..6e7b60d  origin/master -> master

    cd ../xtemp
    git status

        # now it's messed up here too

    # Try with "--update-head-ok" but check first.

    cd ../xtemp-wt2

    git fetch . origin/master:xtemp-wt2

        fatal: Refusing to fetch into current branch refs/heads/xtemp-wt2 of non-bare repository
        fatal: The remote end hung up unexpectedly

    git fetch --update-head-ok . origin/master:xtemp-wt2
        
        From .
           b4d1278..6e7b60d  origin/master -> xtemp-wt2



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

* Re: Bug^Feature? fetch protects only current working tree branch
  2017-07-23 14:50 Bug^Feature? fetch protects only current working tree branch Andreas Heiduk
@ 2017-07-23 22:13 ` Junio C Hamano
  2017-07-24 21:51   ` Andreas Heiduk
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2017-07-23 22:13 UTC (permalink / raw)
  To: Andreas Heiduk; +Cc: Git Mailing List

Andreas Heiduk <andreas.heiduk@mathema.de> writes:

> A `git fetch . origin/master:master` protects the currently checked out 
> branch (HEAD) unless the `-u/--update-head-ok` is supplied. This avoids a
> mismatch between the index and HEAD. BUT branches which are HEADs in other
> working trees do not get that care - their state is silently screwed up.
>
> Is this intended behaviour or and just an oversight while implementing
> `git worktree`?

The latter.  "git worktree" is an interesting feature and has
potential to become useful in wider variety of workflows than it
currently is, but end users should consider it still experimental as
it still is with many such small rough edges like this one.

Patches to help improving the feature is of course very welcome.

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

* Re: Bug^Feature? fetch protects only current working tree branch
  2017-07-23 22:13 ` Junio C Hamano
@ 2017-07-24 21:51   ` Andreas Heiduk
  0 siblings, 0 replies; 3+ messages in thread
From: Andreas Heiduk @ 2017-07-24 21:51 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andreas Heiduk, Git Mailing List

Am 24.07.2017 um 00:13 schrieb Junio C Hamano:
> Andreas Heiduk <andreas.heiduk@mathema.de> writes:
> 
>> A `git fetch . origin/master:master` protects the currently checked out 
>> branch (HEAD) unless the `-u/--update-head-ok` is supplied. This avoids a
>> mismatch between the index and HEAD. BUT branches which are HEADs in other
>> working trees do not get that care - their state is silently screwed up.
>>
>> Is this intended behaviour or and just an oversight while implementing
>> `git worktree`?
> 
> The latter.  

Ok, so I can adjust some of my helper scripts to catch and forbid this case.

> [...]"git worktree" is an interesting feature and has
> potential to become useful in wider variety of workflows than it
> currently is, but end users should consider it still experimental as
> it still is with many such small rough edges like this one.
> 
> Patches to help improving the feature is of course very welcome.

Since the core of the check is in C, I'll pass on this one. I could
supply a patch adding this to the "BUGS" section of git-worktree(1)
though :-)



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

end of thread, other threads:[~2017-07-24 21:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-23 14:50 Bug^Feature? fetch protects only current working tree branch Andreas Heiduk
2017-07-23 22:13 ` Junio C Hamano
2017-07-24 21:51   ` Andreas Heiduk

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).