We unconditionally ask for ahead-behind:HEAD in get_branches() which is okay unless HEAD cannot get resolved. E.g. on a new repo without any commits, the initial branch "main" might get created and HEAD might then refer to "refs/heads/main" but this file does not exist as there are no commits yet.
Just run without AheadBehind in that case.
As this is a rare case call for-each-ref as before but check for the error to call it again without ahead-before:HEAD. This is efficient for the 99.99% use-case.
We unconditionally ask for
ahead-behind:HEAD
inget_branches()
which is okay unless HEAD cannot get resolved. E.g. on a new repo without any commits, the initial branch "main" might get created and HEAD might then refer to "refs/heads/main" but this file does not exist as there are no commits yet.Just run without
AheadBehind
in that case.As this is a rare case call
for-each-ref
as before but check for the error to call it again withoutahead-before:HEAD
. This is efficient for the 99.99% use-case.