Simon
skagedal.tech
Simon
@skagedal.tech
Very interesting, thanks! Although I'm not on Windows myself :)
January 5, 2026 at 7:58 PM
(Which is indeed a relevant amount of faster compared to the shell version, contrary to what I claimed above! I think I might have measured incorrectly. But this all seems to vary quite a bit. But eithe way, the config didn't seem to help.)
January 5, 2026 at 3:15 PM
Let's try this one.

git config --global core.untrackedCache true

With this setting, I've now been running the rust version of my git-dirty-checker under hyperfine to measure run time. It doesn't seem to make much of a difference. Around 210 ms for each run, with or without the option.
January 5, 2026 at 3:11 PM
There is also the "untracked cache":

git-scm.com/docs/git-upd...

I'm not exactly sure how these options relate to, or play along with, each other...
Git - git-update-index Documentation
git-scm.com
January 5, 2026 at 2:57 PM
Seems like it'd be nice to have some kind of cache that gets invalidated on file system activity. Git actually has something exactly like this built-in, the fs-monitor:

git-scm.com/docs/git-fsm...

Is that of any help to our use case?
Git - git-fsmonitor--daemon Documentation
git-scm.com
January 5, 2026 at 2:38 PM
it('sums correctly', () => {
expect(sum(3, 0)).toEqual(3);
});

Seems to work fine!
January 5, 2026 at 1:58 PM
And it's not about shelling out to git. It simply takes some time to do a "git status" – it needs to traverse through the directory tree to find any files not in the git index.
January 5, 2026 at 1:49 PM
So this approach is still way too slow for the kind of use case I discussed above. And it's not a matter of programming language. For example, I have a Rust version under here:

github.com/skagedal/ska...

It does the same job in about 0.45 seconds.
skagedal-tools/git-dirty-checker at main · skagedal/skagedal-tools
A place to put small tools. Contribute to skagedal/skagedal-tools development by creating an account on GitHub.
github.com
January 5, 2026 at 1:46 PM
Adding parallelism (here using GNU parallel) helps a lot:

printf '%s\n' ~/code/*/ | parallel 'git -C {} status --porcelain 2>/dev/null | grep -q . && realpath {}'

On the same set of repos, this takes 0.5 seconds.
January 5, 2026 at 10:45 AM
To take one step back, here's a brute force solution as a bash one-liner:

for dir in ~/code/*/; do git -C "$dir" status --porcelain 2>/dev/null | grep -q . && realpath "$dir"; done

This takes about 10 seconds on my example set.
January 5, 2026 at 10:38 AM
Imagine the end goal use case something like this:

my shell prompt should include the number of dirty repositories under my ~/code directory.

Clearly, assuming that I have let's say hundreds of repos, this means caching. But how?
January 5, 2026 at 9:55 AM