Skip to content

Commit f9c4079

Browse files
committed
fix comment, fix windows
1 parent 1bfc8f3 commit f9c4079

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/git/repo_base_gogit.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
gitealog "code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/setting"
1616

17+
"github.com/go-git/go-billy/v5"
1718
"github.com/go-git/go-billy/v5/osfs"
1819
gogit "github.com/go-git/go-git/v5"
1920
"github.com/go-git/go-git/v5/plumbing"
@@ -62,9 +63,14 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
6263
return nil, err
6364
}
6465
}
65-
// the "clone --shared" repo has alternative paths like "../../../../../../../../gitea-repositories/user2/repo-pull-request-target.git/objects", such relative path doesn't work well with go-git's AlternatesFS at the moment.
66+
// the "clone --shared" repo doesn't work well with go-git AlternativeFS, https://github.com/go-git/go-git/issues/1006
6667
// so use "/" for AlternatesFS, I guess it is the same behavior as current nogogit (no limitation or check for the "objects/info/alternates" paths), trust the "clone" command executed by the server.
67-
altFs := osfs.New("/") // TODO: does it really work for Windows? Need some time to check.
68+
var altFs billy.Filesystem
69+
if setting.IsWindows {
70+
altFs = osfs.New(filepath.VolumeName(setting.RepoRootPath) + "\\") // TODO: does it really work for Windows? Need some time to check.
71+
} else {
72+
altFs = osfs.New("/")
73+
}
6874
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold, AlternatesFS: altFs})
6975
gogitRepo, err := gogit.Open(storage, fs)
7076
if err != nil {

0 commit comments

Comments
 (0)