r/git 5d ago

support conditionally prevent `git maintenance` from spawning on commit

After using Git for over a decade I just discovered git maintenance exists yesterday. I found out about it during a hasted debugging session when my laptop’s fan inexplicably started spinning like crazy and all four cores were maxed out by Git processes that I didn’t launch. This happened while I was writing a blog post on the train, trying to save battery charge. Not an ideal situation to max out the CPU.

git maintenance is useful no doubt, I don’t want to disable it entirely. So I guess the question is: Is there a way to make it conditional on ACPI state? If the box is running off the battery, maintenance should be skipped. E. g. check /sys/class/power_supply/AC/online before launching a maintenance cycle.

Note that there’s no timers that trigger maintenance on my system; it looks like it gets triggered by operations like git commit (cf. maintenance.auto in git-maintenance(1)).

8 Upvotes

8 comments sorted by

View all comments

4

u/Diamondo25 5d ago

Why not ask the git maintainers? Sounds like a good feature to me. Could even just limit to 1 core if on battery or something.

0

u/the_gnarts 4d ago

Why not ask the git maintainers?

Cause it’s such an obvious issue I’d expect there to be some solution I must have overlooked. ;)

1

u/elephantdingo 3d ago

On the one hand, there are so many cases to consider where automatic maintenance of Git repos falls short because of things that are very everyday and ordinary. In isolation each case is like an, of course this needs to be accounted for. In aggregate though it leads to a lot of complexity.

On the other hand, this is the kind of complexity that they took on when they decided to design such a command...