aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vcs/git.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/vcs/git.go')
-rw-r--r--pkg/vcs/git.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go
index bc0e05373..f73c47c58 100644
--- a/pkg/vcs/git.go
+++ b/pkg/vcs/git.go
@@ -16,6 +16,7 @@ import (
"strings"
"time"
+ "github.com/google/syzkaller/pkg/hash"
"github.com/google/syzkaller/pkg/osutil"
)
@@ -87,13 +88,20 @@ func (git *git) CheckoutCommit(repo, commit string) (*Commit, error) {
return nil, err
}
}
- _, err := runSandboxed(dir, "git", "fetch", repo)
- if err != nil {
+ if err := git.fetchRemote(repo); err != nil {
return nil, err
}
return git.SwitchCommit(commit)
}
+func (git *git) fetchRemote(repo string) error {
+ repoHash := hash.String([]byte(repo))
+ // Ignore error as we can double add the same remote and that will fail.
+ runSandboxed(git.dir, "git", "remote", "add", repoHash, repo)
+ _, err := runSandboxed(git.dir, "git", "fetch", repoHash)
+ return err
+}
+
func (git *git) SwitchCommit(commit string) (*Commit, error) {
dir := git.dir
if _, err := runSandboxed(dir, "git", "checkout", commit); err != nil {