FindCommits regression causes a failure when listing commits of an empty repository
From gitlab#452488 (comment 1841380686)
The MR (!6590 (merged)) fixed an issue with FindCommits
that was leading it to ignore errors. After the MR, the errors are actually returned to the caller. It appears api/v4/projects/199/repository/commits
has always caused a failure in Gitaly but it is now being surfaced due to the error handling being fixed.
The default request sent by the endpoint doesn't define a revision. Gitaly then defaults to using the default branch here. Due to legacy reasons, the default branch used is not just the value of HEAD
. As the repository contains no branches, a fallback is triggered and an empty revision is returned here. The result is that Git fails with fatal: ambiguous argument '': unknown revision or path not in the working tree.
. The regex checking for this error message expects at least one character in the single quotes. As the message doesn't have anything, it's treated as a general error and leads to the failure here.
This should be get fixed in Gitaly as the behavior of the API has changed. Semantically it makes sense to return empty set of commits and not fail on an empty repository.