wafsamba: Override GIT_DIR without using putenv.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 3 Dec 2010 02:10:27 +0000 (03:10 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 3 Dec 2010 03:24:53 +0000 (04:24 +0100)
putenv has sideffects on later code. This overrides GIT_DIR for just this call.

Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Fri Dec  3 04:24:53 CET 2010 on sn-devel-104

buildtools/wafsamba/samba_version.py

index 076615b6c46a5c2522d5637b9725036d13e3e307..4f99b2c08774865811444e53a6f982ebb7a08eb8 100644 (file)
@@ -49,9 +49,10 @@ def git_version_summary(path, env=None):
     if not 'GIT' in env:
         return ("GIT-UNKNOWN", {})
 
-    os.putenv('GIT_DIR', '%s/.git' % path)
-    os.putenv('GIT_WORK_TREE', path)
-    git = Utils.cmd_output(env.GIT + ' show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True)
+    environ = dict(os.environ)
+    environ["GIT_DIR"] = '%s/.git' % path
+    environ["GIT_WORK_TREE"] = path
+    git = Utils.cmd_output(env.GIT + ' show --pretty=format:"%h%n%ct%n%H%n%cd" --stat HEAD', silent=True, env=environ)
 
     lines = git.splitlines()
     if not lines or len(lines) < 4: