Backport bug fix in MR 2497 to 13.3 stable branch
This change backports a fix from !2497 (merged) to stable branch 13.3 of Gitaly. The commits ffdac2a7 and 3f880eab were directly cherry picked to create this MR.
This change backports a fix from !2497 (merged) to stable branch 13.3 of Gitaly. The commits ffdac2a7 and 3f880eab were directly cherry picked to create this MR.