-
Notifications
You must be signed in to change notification settings - Fork 534
storage: filesystem, add support for git alternates #663
Conversation
You will need to create a fixture with altnernates and pull request it to: https://github.com/src-d/go-git-fixtures |
storage/filesystem/object.go
Outdated
// alternates file. | ||
fs := osfs.New(filepath.Dir(alt)) | ||
dir := dotgit.New(fs) | ||
o, oe := newObjectStorage(dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this secondary storage object should be cached rather than recreated each time we retrieve an object stored in the alternates?
func (d *DotGit) Module(name string) (billy.Filesystem, error) { | ||
return d.fs.Chroot(d.fs.Join(modulePath, name)) | ||
} | ||
|
||
// Alternates returns the content of objects/info/alternates if available. | ||
// This can be used to checks if it's a shared repository. | ||
func (d *DotGit) Alternates() (string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would be better if this returned (*DotGit, error)
instead of just the file contents?
415a31f
to
0c23406
Compare
@orirawlings some hints on how to cache storage object would be great :) |
NOTE: The test |
0c23406
to
53fdfe6
Compare
This change adds a new method `Alternates()` in `DotGit` to check and query alternate source. ``` func (d *DotGit) Alternates() (string, error) ``` This is used by `ObjectStorage.EncodedObject` to check for alternates and get the queried object from the alternate source.
82e5f16
to
3aa04f1
Compare
3aa04f1
to
4b6f4c8
Compare
Alright, so there were two issues, both related to the paths on Windows. Glad that it was caught. Failure in dotgit_test.go was due to the hard-coded separators. Replaced them with Issue in worktree_test.go was due to the alternates in the worktree fixture being in *nix style slash path, which lead to unknown path on windows. Added an internal conversion of relative paths to slash path to solve this issue. |
Awesome! |
This change adds a new method
Alternates()
inDotGit
to check andquery alternate source.
This is used by
ObjectStorage.EncodedObject
to check for alternatesand get the queried object from the alternate source.
I've manually tested this with the scenario and code in #325 but I'm not sure what would be the right way to setup an automated test for this. Need help with testing.
Fixes #325