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

Re: race condition when pushing

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Nov 17, 2015, 13:25 UTC
Message-ID
<alpine.DEB.1.00.1511171419130.1686@s15462909.onlinehome-server.info>
In-Reply-To
<CAPig+cSGSe=7PY7HVuAdy=4chbkkACiEBZzvDA4AktMKFiRfPw@mail.gmail.com>
Hi Lyle & Eric,
On Thu, 5 Nov 2015, Eric Sunshine wrote:
Show 25 quoted lines
> On Thu, Nov 5, 2015 at 11:11 AM, Lyle Ziegelmiller <lyle_z@hotmail.com> wrote:
> > git push --set-upstream  has some sort of race condition. Some times
> > when I execute it, it works. Other times, it does not. Below is from
> > my command window. I've executed the exact same command (using bash
> > history re-execution, so I know I didn't make a typo), repeatedly.
> > Notice the last execution results in an error. I am the only person on
> > my machine. This is non-deterministic behavior.
> >
> > lylez@LJZ-DELLPC ~/gittest/local
> > $ git push --set-upstream origin localbranch1
> > Branch localbranch1 set up to track remote branch localbranch1 from origin.
> > Everything up-to-date
> >
> > lylez@LJZ-DELLPC ~/gittest/local
> > $ git push --set-upstream origin localbranch1
> > Branch localbranch1 set up to track remote branch localbranch1 from origin.
> > Everything up-to-date
> >
> > lylez@LJZ-DELLPC ~/gittest/local
> > $ git push --set-upstream origin localbranch1
> > error: could not commit config file .git/config
> > Branch localbranch1 set up to track remote branch localbranch1 from origin.
> > Everything up-to-date
> >
> > I'm using Git in a Cygwin window on a 32-bit Windows 10 machine.
Are you using Cygwin's own Git, or Git for Windows, or something else?
> If I recall correctly, the typical culprit is a Windows virus scanner
> (or even an indexer) locking the file, so git is unable to manipulate
> it.

In Git for Windows, we have code to work around this issue by detecting in-use files and waiting for a staggered amount of time to re-try:

https://github.com/git-for-windows/git/blob/c6f19b078bf05643c4d50dd520280a80f19f0002/compat/mingw.c#L208-L231
This is used e.g. by our `rename()` wrapper:
https://github.com/git-for-windows/git/blob/c6f19b078bf05643c4d50dd520280a80f19f0002/compat/mingw.c#L1859-L1904

Please note that this code is active in Git for Windows (i.e. the *MinGW* version of Git) but not in Cygwin Git (nor the MSys2 version of Git).

Ciao, Dscho

Previous: Eric SunshineNext: Johannes Schindelin
Message 3 of 4 in “race condition when pushing”
  1. Lyle ZiegelmillerNov 5, 2015
  2. Eric SunshineNov 5, 2015
  3. Johannes SchindelinNov 17, 2015
  4. Johannes SchindelinNov 18, 2015

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.