Skip to content

Commit 07cf206

Browse files
committed
fix comment, fix windows
1 parent 1bfc8f3 commit 07cf206

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/git/repo_base_gogit.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,14 @@ func OpenRepository(ctx context.Context, repoPath string) (*Repository, error) {
6262
return nil, err
6363
}
6464
}
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.
65+
// the "clone --shared" repo doesn't work well with go-git AlternativeFS, https://github.com/go-git/go-git/issues/1006
6666
// 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.
67+
var altFs billy.Filesystem
68+
if setting.IsWindows {
69+
altFs = osfs.New(filepath.VolumeName(setting.RepoRootPath) + "\\") // TODO: does it really work for Windows? Need some time to check.
70+
} else {
71+
altFs = osfs.New("/")
72+
}
6873
storage := filesystem.NewStorageWithOptions(fs, cache.NewObjectLRUDefault(), filesystem.Options{KeepDescriptors: true, LargeObjectThreshold: setting.Git.LargeObjectThreshold, AlternatesFS: altFs})
6974
gogitRepo, err := gogit.Open(storage, fs)
7075
if err != nil {

0 commit comments

Comments
 (0)