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

Shallow clones: ctime shouldn't be used on FreeBSD with UFS + soft-updates

From
Jessica Clarke <jrtc27@jrtc27.com>
Date
Dec 2, 2026, 18:10 UTC
Message-ID
<41F956FA-64BC-4F68-8619-2E8B9889C26F@jrtc27.com>

Hi, Git uses ctime in various ways, but one of them is to check that the shallow file has not changed since the last time it was read during a shallow clone. In the case of the shallow file, it comes into being by being renamed from shallow.lock, and is then immediately stat’ed to give the before value. However, FreeBSD’s UFS soft-updates implementation has slightly surprising semantics for unlink (and internally uses link + unlink to implement rename): it will update ctime at the point of unlink (and thus rename), but will *also* later update it once its asynchronous soft-updates work is finished (see [1] that explains this latter update, and introduces the former). This means that, if Git is keying off ctime to determine whether shallow has changed, it can race with this soft-updates code and potentially sample either side of it, seeing the value change solely due to internal bookkeeping work in the filesystem.

As a result, I see git submodule update --depth=1 some/path sporadically fail on a FreeBSD 15.0-RELEASE-p11 (but as far as I know not limited to this version) builder we have, with:

> fatal: shallow file has changed since we read it

I have set core.trustctime to false in the build user’s ~/.gitconfig as a workaround. However, I imagine that other uses for ctime might be tolerant of this behaviour, just leading to minor inefficiency, and so having this default to false on FreeBSD might be a bit too broad a fix? I don’t take a strong view on what the right fix is, but would appreciate it if Git could by default on FreeBSD not use ctime to determine whether the shallow file has changed.

I doubt it matters, but this is with Git 2.56.0, for what it’s worth.
Also, here’s an illustration this behaviour (whole script is set -x):
Show 16 quoted lines
> $ ./ctime-after-mv
> + rm -fv foo bar
> bar
> + touch foo
> + stat -f %Fc foo
> 1796226770.687840000
> + sleep 2
> + stat -f %Fc foo
> 1796226770.687840000
> + sleep 2
> + mv foo bar
> + stat -f %Fc bar
> 1796226774.694149000
> + sleep 2
> + stat -f %Fc bar
> 1796226775.523101000

Thanks, Jessica

[1] https://cgit.freebsd.org/src/commit/?id=1a75045196a26c2dd00a03a3d6d231dd5b422a9b
Next: brian m. carlson
Message 1 of 2 in “Shallow clones: ctime shouldn't be used on FreeBSD with UFS + soft-updates”
  1. Jessica ClarkeDec 2, 2026
  2. brian m. carlsonDec 2, 2026

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.