Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support serving bare repositories #634

Open
andir opened this issue Oct 20, 2021 · 3 comments
Open

Support serving bare repositories #634

andir opened this issue Oct 20, 2021 · 3 comments

Comments

@andir
Copy link
Contributor

andir commented Oct 20, 2021

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.

@mrnugget
Copy link
Contributor

Hey @andir!

I might be wrong, but it looks to me like src serve-git already supports bare git repositories:

// Check whether a repository is a bare repository or not.
//
// If it yields false, which means it is a non-bare repository,
// skip the directory so that it will not recurse to the subdirectories.
// If it is a bare repository, proceed to recurse.
c := exec.Command("git", "rev-parse", "--is-bare-repository")
c.Dir = gitdir
out, _ := c.CombinedOutput()
if string(out) == "false\n" {
return filepath.SkipDir
}
return nil

@keegancsmith would know best, though. So, ping :)

@andir
Copy link
Contributor Author

andir commented Oct 20, 2021

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.

@keegancsmith
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants