git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git fetch <remote> <branch> behaves weirdely when run in a worktree

From
Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
Date
Oct 2, 2018, 18:43 UTC
Message-ID
<d876e0af6a860621ae80fde71069c5e2e6a71878.camel@gmail.com>
In-Reply-To
<xmqqpnx0mbos.fsf@gitster-ct.c.googlers.com>
Hi,

Sorry for the delay. Got a little busy over the weekend. I seem to have found the reason behind the issue in the mean time :-)

On Wed, 2018-09-26 at 10:05 -0700, Junio C Hamano wrote:
Show 18 quoted lines
> Duy Nguyen <pclouds@gmail.com> writes:
> 
> > On Wed, Sep 26, 2018 at 05:24:14PM +0200, Duy Nguyen wrote:
> > > On Wed, Sep 26, 2018 at 6:46 AM Kaartic Sivaraam
> > > <kaartic.sivaraam@gmail.com> wrote:
> > > > This is the most interesting part of the issue. I **did not** run
> > > > 'git fetch ...' in between those cat commands. I was surprised by
> > > > how the contents of FETCH_HEAD are changing without me spawning any
> > > > git processes that might change it. Am I missing something here? As
> > > > far as i could remember, there wasn't any IDE running that might
> > > > automatically spawn git commands especially in that work
> > > > tree. Weird.
> > 
> > Maybe something like this could help track down that rogue "git fetch"
> > process (it's definitely _some_ process writing to the wrong file; or
> > some file synchronization thingy is going on). You can log more of
> > course, but this is where FETCH_HEAD is updated.
> 
Thanks for the patch! It really helped me identify the issue.

The actual culprit here doesn't seem to be Git itself. It was the "git- prompt" bash plug-in[1] I was using. It seems to be spawning "git fetch" for every command I type on shell. That answers why the FETCH_HEAD was being updated even though I wasn't explicitly running it. The git bash plug-in seems to be fetching changes for *all* the upstream branches. That answers why there FETCH_HEAD was populated with info about all the branches when I explicitly requested for the next branch. I've also verified that `git fetch origin next` works as intended (FETCH_HEAD has info only about orgin/next) when I turn-off the plug-in which confirms that it's the culprit. A cursory search found me a related issue[2] but I'm not sure if it's the exact same one.

I could identify the culprit only with the help of Duy's patch. Thanks Duy! Sorry for not realising this earlier. I almost forgot I'm using it as I've been accustomed to it a lot.

> Well, a background-ish thing could be some vendor-provided copy of
> Git that has nothing to do with what Kaartic would be compiling with
> this patch X-<.

Fortunately, it wasn't the case here as the plug-in was using my manually-built version of Git :-)

Thanks for the help!
Tag-line: Sometimes tools become part of our workflow so much that we
really don't realise their presence. It's an indication of a good tool
but we should be aware of suspecting them when an issue arises!
Something which I should have done to realise the issue ealier x-<

References: [1]: https://github.com/magicmonty/bash-git-prompt [2]: https://github.com/magicmonty/bash-git-prompt/issues/125

Thanks, Sivaraam

Previous: Junio C HamanoNext: Kaartic Sivaraam
Message 10 of 12 in “git fetch <remote> <branch> behaves weirdely when run in a worktree”
  1. Kaartic SivaraamSep 23, 2018
  2. Duy NguyenSep 24, 2018
  3. Kaartic SivaraamSep 25, 2018
  4. Junio C HamanoSep 25, 2018
  5. Kaartic SivaraamSep 26, 2018
  6. Kaartic SivaraamSep 26, 2018
  7. Duy NguyenSep 26, 2018
  8. Duy NguyenSep 26, 2018
  9. Junio C HamanoSep 26, 2018
  10. Kaartic SivaraamOct 2, 2018
  11. Kaartic SivaraamOct 4, 2018
  12. Duy NguyenOct 4, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.