Support serving bare repositories
On my Git host I've all the repositories in "bare" format. They have been created using git init --bare $name and thus do not have a .git folder within them. The repositories don't need a full checkout nor a .git folder when being accessed via SSH. Currently serving those repositories doesn't work as the check for .git folder within them fails.
On the filesystem the layout looks like this:
/data
/data/foo.git
/data/bar.git
/data/project1/zes.git
/data/project2/des.git
...
Ideally each of the repositories would appear with their name with the .git suffix stripped (foo, bar, project1/zes, ...).
Is this something you'd like in the upstream code base? I wouldn't mind trying to tackle the issue as the original code seems to have enough test coverage for me to be confident in not breaking stuff on the way.
Hey @andir!
I might be wrong, but it looks to me like src serve-git already supports bare git repositories: https://github.com/sourcegraph/src-cli/blob/3a48ac72cbe0dc31a69400bd6a062f7104fde858/internal/servegit/serve.go#L183-L196
@keegancsmith would know best, though. So, ping :)
That only works if you have a directory named .git within the repos directory. In my case the repository folder is basically the .git folder.
It is difficult to detect a bare git repository generally which is why we rely on the .git convention. You also run into problems on sub repos.
However, saying that we may have something which works enough of the time and is performant: check for a HEAD file and objects dir. I feel like this is an acceptable option.