aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/vcs/git_test_util.go
diff options
context:
space:
mode:
authorAndrew Donnellan <ajd@linux.ibm.com>2019-12-12 17:04:58 +1100
committerDmitry Vyukov <dvyukov@google.com>2019-12-12 09:56:25 +0100
commit08003f6440deafc4e193b159c4acece64f7864b1 (patch)
tree6c788af0742acb9a0f3d5fc6daf4fa1d8c8cadab /pkg/vcs/git_test_util.go
parentdf191c7fd0bb6b36fbf55791a49f3c1daa3135e9 (diff)
pkg/vcs: Unset various git environment variables when invoking git
If you try to run git-using tests while the GIT_DIR environment variable (and GIT_WORK_TREE, etc) happens to be set, the tests are going to do fun and exciting things on a repository that isn't the test repository it tries to set up. As it turns out, if you try to run "make test" using git rebase -x, you'll end up with GIT_DIR set to the syzkaller tree. Hilarity ensues. Unset GIT_DIR, GIT_WORK_TREE and a few other environment variables when invoking git - that way it'll default to looking at the working directory that we have given it, which is what we expect. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com>
Diffstat (limited to 'pkg/vcs/git_test_util.go')
-rw-r--r--pkg/vcs/git_test_util.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkg/vcs/git_test_util.go b/pkg/vcs/git_test_util.go
index 86713bac0..2f050a2b2 100644
--- a/pkg/vcs/git_test_util.go
+++ b/pkg/vcs/git_test_util.go
@@ -25,7 +25,11 @@ type TestRepo struct {
}
func (repo *TestRepo) Git(args ...string) {
- if _, err := osutil.RunCmd(time.Minute, repo.Dir, "git", args...); err != nil {
+ cmd := osutil.Command("git", args...)
+ cmd.Dir = repo.Dir
+ cmd.Env = filterEnv()
+
+ if _, err := osutil.Run(time.Minute, cmd); err != nil {
repo.t.Fatal(err)
}
}