git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* git fetch <remote> <branch> behaves weirdely when run in a worktree
@ 2018-09-23 20:09 Kaartic Sivaraam
  2018-09-24 15:17 ` Duy Nguyen
  2018-09-26  4:46 ` Kaartic Sivaraam
  0 siblings, 2 replies; 12+ messages in thread
From: Kaartic Sivaraam @ 2018-09-23 20:09 UTC (permalink / raw)
  To: Git Users

Hi,

I was actually trying to automae the building and installation of Git
source code to reduce my burden. I tried to automate it with the help
of a script that runs daily via cron and a separate worktree used only
by the build script.y run

The script typically fetches new changes for the next branch by running
the following in the build worktree (which is not the main worktree):

   $ git fetch origin next

I thought that would result in FETCH_HEAD pointing to the latest
changes for origin/next if the command succeeded.

Unfortunately, it seems to be behaving weirdely when run in a worktree.
It sems to be behaving as if I ran 'git fetch origin'. To add to that
confusion when I run

   $ cat $MAIN_WORKTREE/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD

it seems to be printing the info about the remote refs once and then if
I run it again immediately nothing is printed. If I repeat it again,
info about remote refs is printed but this time the info about the
remote refs is printed thrice. This happens randomly. Sample output:

   01:23 $ cat ../git/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD 
   53f9a3e157dbbc901a02ac2c73346d375e24978c	not-for-merge	branch 'maint' of https://github.com/git/git
150f307afc13961b0322ad0e7205a7b193368586	not-for-merge	branch 'master' of https://github.com/git/git
01d371f741e6f0b0076d9ed942d99bdb23757eac	not-for-merge	branch 'next' of https://github.com/git/git
7a81cbc028be113058e0b55062706ec6de62ed94	not-for-merge	branch 'pu' of https://github.com/git/git
722746685bce03f223ed75febe312495e6c139da	not-for-merge	branch 'todo' of https://github.com/git/git
   01:23 $ cat ../git/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD 
   01:23 $ cat ../git/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD 
   01:23 $ cat ../git/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD 
   53f9a3e157dbbc901a02ac2c73346d375e24978c	not-for-merge	branch 'maint' of https://github.com/git/git
150f307afc13961b0322ad0e7205a7b193368586	not-for-merge	branch 'master' of https://github.com/git/git
01d371f741e6f0b0076d9ed942d99bdb23757eac	not-for-merge	branch 'next' of https://github.com/git/git
7a81cbc028be113058e0b55062706ec6de62ed94	not-for-merge	branch 'pu' of https://github.com/git/git
722746685bce03f223ed75febe312495e6c139da	not-for-merge	branch 'todo' of https://github.com/git/git
53f9a3e157dbbc901a02ac2c73346d375e24978c	not-for-merge	branch 'maint' of https://github.com/git/git
150f307afc13961b0322ad0e7205a7b193368586	not-for-merge	branch 'master' of https://github.com/git/git
01d371f741e6f0b0076d9ed942d99bdb23757eac	not-for-merge	branch 'next' of https://github.com/git/git
7a81cbc028be113058e0b55062706ec6de62ed94	not-for-merge	branch 'pu' of https://github.com/git/git
722746685bce03f223ed75febe312495e6c139da	not-for-merge	branch 'todo' of https://github.com/git/git
53f9a3e157dbbc901a02ac2c73346d375e24978c	not-for-merge	branch 'maint' of https://github.com/git/git
150f307afc13961b0322ad0e7205a7b193368586	not-for-merge	branch 'master' of https://github.com/git/git
01d371f741e6f0b0076d9ed942d99bdb23757eac	not-for-merge	branch 'next' of https://github.com/git/git
7a81cbc028be113058e0b55062706ec6de62ed94	not-for-merge	branch 'pu' of https://github.com/git/git
722746685bce03f223ed75febe312495e6c139da	not-for-merge	branch 'todo' of https://github.com/git/git
   01:23 $ cat ../git/.git/worktrees/$BUILD_WORKTREE/FETCH_HEAD 
   53f9a3e157dbbc901a02ac2c73346d375e24978c	not-for-merge	branch 'maint' of https://github.com/git/git
150f307afc13961b0322ad0e7205a7b193368586	not-for-merge	branch 'master' of https://github.com/git/git
01d371f741e6f0b0076d9ed942d99bdb23757eac	not-for-merge	branch 'next' of https://github.com/git/git
7a81cbc028be113058e0b55062706ec6de62ed94	not-for-merge	branch 'pu' of https://github.com/git/git
722746685bce03f223ed75febe312495e6c139da	not-for-merge	branch 'todo' of https://github.com/git/git

   'git fetch <remote> <branch>' behaves correctly in the main worktree.

   Why is this weirdness happening when run in other worktrees?

   Why isn't 'git fetch <remote> <branch> not fetching the changes for
   just the specified branch?

   Am I missing something?

   --
   Sivaraam


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

end of thread, other threads:[~2018-10-04  7:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-23 20:09 git fetch <remote> <branch> behaves weirdely when run in a worktree Kaartic Sivaraam
2018-09-24 15:17 ` Duy Nguyen
2018-09-25 18:44   ` Kaartic Sivaraam
2018-09-25 21:40     ` Junio C Hamano
2018-09-26  3:37       ` Kaartic Sivaraam
2018-09-26  4:46 ` Kaartic Sivaraam
2018-09-26 15:24   ` Duy Nguyen
2018-09-26 16:09     ` Duy Nguyen
2018-09-26 17:05       ` Junio C Hamano
2018-10-02 18:43         ` Kaartic Sivaraam
2018-10-04  6:54           ` Kaartic Sivaraam
2018-10-04  7:00             ` Duy Nguyen

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).