Subject: Re: Why do we need to wait 1s between a git add and commit

From: "Kristoffer Haugsbakk" <[email-masked]>
Date: Fri, 22 May 2026 17:12:21 +0200

Hi

On Fri, May 22, 2026, at 14:28, Fabrice SALVAIRE wrote:
> I wrote a Python tool to dump a wiki to a git repository, that does
> basically a succession of subprocess calls to git add and commit.
>
> Recently, I discovered this tool doesn't work any longer and that git
> commit (2.54 on Fedora 42 / 43) crashes randomly.
>
> I cannot explain this behavior since my code is trivial.
>
> I had the intuition to add a sleep time of 1s just after a git call, and
> it solves the issue.
>
> I noticed for some cases that another call to git commit were
> successful. For most cases, git fsck and gitk report issues.
>
> It looks like the state of the git repository was not yet completed
> before the end of the git subprocess.

This might be caused by git-maintenance(1) being run in the background
without locking? That’s a new issue in Git 2.54.0. See:

https://lore.kernel.org/git/[email-masked]/

The following script reproduces the issue on Git 2.53.0. I am guessing
that your script does something similar? It depends on how many commits
it creates in a short timeframe.

https://lore.kernel.org/git/[email-masked]/