MCPcopy Index your code
hub / github.com/go-git/go-git / Module

Method Module

storage/filesystem/dotgit/dotgit.go:1141–1148  ·  view source on GitHub ↗

Module returns a billy.Filesystem pointing to the module folder. As a defence in depth against submodule name path traversal, refuse names whose joined path leaves the modules/ subtree once cleaned. The config-layer parser also validates submodule names, but Module may be reached from any caller th

(name string)

Source from the content-addressed store, hash-verified

1139// but Module may be reached from any caller that constructs a
1140// Submodule struct programmatically and so bypasses the parser.
1141func (d *DotGit) Module(name string) (billy.Filesystem, error) {
1142 p := d.fs.Join(modulePath, name)
1143 cleaned := path.Clean(filepath.ToSlash(p))
1144 if cleaned != modulePath && !strings.HasPrefix(cleaned, modulePath+"/") {
1145 return nil, ErrModuleNameEscape
1146 }
1147 return d.fs.Chroot(p)
1148}
1149
1150func (d *DotGit) AddAlternate(remote string) error {
1151 altpath := d.fs.Join(objectsPath, infoPath, alternatesPath)

Callers

nothing calls this directly

Calls 3

JoinMethod · 0.80
CleanMethod · 0.80
ChrootMethod · 0.45

Tested by

no test coverage detected