Skip to content

Fix FindCommits in repositories missing default branches

Sami Hiltunen requested to merge smh-fix-find-commits-empty into master

A regression was introduced in FindCommits recently in 588d901f. The commit fixed the RPC to actually wait for the git log command and return a possible error that may be raised. This surfaced an error where listing the commits fail if the repository is empty. While this case seems to have always errored out, the error started to be only returned after the error handling was fixed. This has lead to behavior changes in Rails' commit listing API that is now failing with internal server error on empty repositories.

Fix the issue by relaxing the regex that is checking for the ambiguous argument case. It currently expects the revision to have at least one character. In the fallback cases in GetDefaultBranch(), an empty string is returned if the repository has no branches. This leads to triggering 'git log ""' which fails due to the non-existent revision.

Closes #5950 (closed)

Merge request reports