if path == "" {
return fmt.Errorf("empty string")
}
+ if path[0] == '-' {
+ return fmt.Errorf("leading dash")
+ }
if strings.Contains(path, "..") {
return fmt.Errorf("double dot")
}
name: "Mercurial",
cmd: "hg",
- createCmd: []string{"clone -U {repo} {dir}"},
+ createCmd: []string{"clone -U -- {repo} {dir}"},
downloadCmd: []string{"pull"},
// We allow both tag and branch names as 'tags'
tagSyncDefault: []string{"update default"},
scheme: []string{"https", "http", "ssh"},
- pingCmd: "identify {scheme}://{repo}",
+ pingCmd: "identify -- {scheme}://{repo}",
remoteRepo: hgRemoteRepo,
}
name: "Git",
cmd: "git",
- createCmd: []string{"clone {repo} {dir}", "-go-internal-cd {dir} submodule update --init --recursive"},
+ createCmd: []string{"clone -- {repo} {dir}", "-go-internal-cd {dir} submodule update --init --recursive"},
downloadCmd: []string{"pull --ff-only", "submodule update --init --recursive"},
tagCmd: []tagCmd{
tagSyncDefault: []string{"submodule update --init --recursive"},
scheme: []string{"git", "https", "http", "git+ssh", "ssh"},
- pingCmd: "ls-remote {scheme}://{repo}",
+ pingCmd: "ls-remote -- {scheme}://{repo}",
remoteRepo: gitRemoteRepo,
}
name: "Bazaar",
cmd: "bzr",
- createCmd: []string{"branch {repo} {dir}"},
+ createCmd: []string{"branch -- {repo} {dir}"},
// Without --overwrite bzr will not pull tags that changed.
// Replace by --overwrite-tags after http://pad.lv/681792 goes in.
tagSyncDefault: []string{"update -r revno:-1"},
scheme: []string{"https", "http", "bzr", "bzr+ssh"},
- pingCmd: "info {scheme}://{repo}",
+ pingCmd: "info -- {scheme}://{repo}",
remoteRepo: bzrRemoteRepo,
resolveRepo: bzrResolveRepo,
}
name: "Subversion",
cmd: "svn",
- createCmd: []string{"checkout {repo} {dir}"},
+ createCmd: []string{"checkout -- {repo} {dir}"},
downloadCmd: []string{"update"},
// There is no tag command in subversion.
// The branch information is all in the path names.
scheme: []string{"https", "http", "svn", "svn+ssh"},
- pingCmd: "info {scheme}://{repo}",
+ pingCmd: "info -- {scheme}://{repo}",
remoteRepo: svnRemoteRepo,
}
name: "Fossil",
cmd: "fossil",
- createCmd: []string{"-go-internal-mkdir {dir} clone {repo} " + filepath.Join("{dir}", fossilRepoName), "-go-internal-cd {dir} open .fossil"},
+ createCmd: []string{"-go-internal-mkdir {dir} clone -- {repo} " + filepath.Join("{dir}", fossilRepoName), "-go-internal-cd {dir} open .fossil"},
downloadCmd: []string{"up"},
tagCmd: []tagCmd{{"tag ls", `(.*)`}},
// but this lets us say git fetch origin instead, which
// is a little nicer. More importantly, using a named remote
// avoids a problem with Git LFS. See golang.org/issue/25605.
- if _, err := Run(r.dir, "git", "remote", "add", "origin", r.remote); err != nil {
+ if _, err := Run(r.dir, "git", "remote", "add", "origin", "--", r.remote); err != nil {
os.RemoveAll(r.dir)
return nil, err
}
statCache par.Cache
refsOnce sync.Once
- refs map[string]string
- refsErr error
+ // refs maps branch and tag refs (e.g., "HEAD", "refs/heads/master")
+ // to commits (e.g., "37ffd2e798afde829a34e8955b716ab730b2a6d6")
+ refs map[string]string
+ refsErr error
localTagsOnce sync.Once
localTags map[string]bool
// statLocal returns a RevInfo describing rev in the local git repository.
// It uses version as info.Version.
func (r *gitRepo) statLocal(version, rev string) (*RevInfo, error) {
- out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev)
+ out, err := Run(r.dir, "git", "-c", "log.showsignature=false", "log", "-n1", "--format=format:%H %ct %D", rev, "--")
if err != nil {
return nil, fmt.Errorf("unknown revision %s", rev)
}
"hg": {
vcs: "hg",
init: func(remote string) []string {
- return []string{"hg", "clone", "-U", remote, "."}
+ return []string{"hg", "clone", "-U", "--", remote, "."}
},
tags: func(remote string) []string {
return []string{"hg", "tags", "-q"}
if subdir != "" {
pattern = []string{"-I", subdir + "/**"}
}
- return str.StringList("hg", "archive", "-t", "zip", "--no-decode", "-r", rev, "--prefix=prefix/", pattern, target)
+ return str.StringList("hg", "archive", "-t", "zip", "--no-decode", "-r", rev, "--prefix=prefix/", pattern, "--", target)
},
},
vcs: "svn",
init: nil, // no local checkout
tags: func(remote string) []string {
- return []string{"svn", "list", strings.TrimSuffix(remote, "/trunk") + "/tags"}
+ return []string{"svn", "list", "--", strings.TrimSuffix(remote, "/trunk") + "/tags"}
},
tagRE: re(`(?m)^(.*?)/?$`),
statLocal: func(rev, remote string) []string {
if rev == "latest" {
suffix = ""
}
- return []string{"svn", "log", "-l1", "--xml", remote + suffix}
+ return []string{"svn", "log", "-l1", "--xml", "--", remote + suffix}
},
parseStat: svnParseStat,
latest: "latest",
readFile: func(rev, file, remote string) []string {
- return []string{"svn", "cat", remote + "/" + file + "@" + rev}
+ return []string{"svn", "cat", "--", remote + "/" + file + "@" + rev}
},
// TODO: zip
},
"bzr": {
vcs: "bzr",
init: func(remote string) []string {
- return []string{"bzr", "branch", "--use-existing-dir", remote, "."}
+ return []string{"bzr", "branch", "--use-existing-dir", "--", remote, "."}
},
fetch: []string{
"bzr", "pull", "--overwrite-tags",
if subdir != "" {
extra = []string{"./" + subdir}
}
- return str.StringList("bzr", "export", "--format=zip", "-r", rev, "--root=prefix/", target, extra)
+ return str.StringList("bzr", "export", "--format=zip", "-r", rev, "--root=prefix/", "--", target, extra)
},
},
"fossil": {
vcs: "fossil",
init: func(remote string) []string {
- return []string{"fossil", "clone", remote, ".fossil"}
+ return []string{"fossil", "clone", "--", remote, ".fossil"}
},
fetch: []string{"fossil", "pull", "-R", ".fossil"},
tags: func(remote string) []string {
}
// Note that vcsRepo.ReadZip below rewrites this command
// to run in a different directory, to work around a fossil bug.
- return str.StringList("fossil", "zip", "-R", ".fossil", "--name", "prefix", extra, rev, target)
+ return str.StringList("fossil", "zip", "-R", ".fossil", "--name", "prefix", extra, "--", rev, target)
},
},
}
if path == "" {
return fmt.Errorf("empty string")
}
+ if path[0] == '-' {
+ return fmt.Errorf("leading dash")
+ }
if strings.Contains(path, "..") {
return fmt.Errorf("double dot")
}
{"/x.y/z", false, false, false},
{"x./z", false, false, false},
{".x/z", false, false, true},
- {"-x/z", false, true, true},
+ {"-x/z", false, false, false},
{"x..y/z", false, false, false},
{"x.y/z/../../w", false, false, false},
{"x.y//z", false, false, false},