Thread (1 message) 1 message, 1 author, 2016-06-15

Re: Fwd: [PATCH] git-p4: chdir now properly sets PWD environment variable in msysGit

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:45:10
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Junio C Hamano [off-list ref] writes:
"Robert Blum" [off-list ref] writes:
quoted
Forgot reply-all - forwarding to list....
...
I have been wondering what happened to this thread afterwards.
In the meantime, here is what I am inclined to apply.  The same approach
as the original, taking stylistic suggestion from Han-Wen.

-- >8 --
From: Robert Blum <redacted>
Date: Fri, 1 Aug 2008 12:50:03 -0700
Subject: [PATCH] git-p4: chdir now properly sets PWD environment variable in msysGit

P4 on Windows expects the PWD environment variable to be set to the
current working dir, but os.chdir in python doesn't do so.

Signed-off-by: Robert Blum <redacted>
Acked-by: Simon Hausmann <redacted>
Acked-by: Han-Wen Nienhuys <redacted>
Signed-off-by: Junio C Hamano <redacted>
---
 contrib/fast-import/git-p4 |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 6ae0429..3f2303d 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,11 @@ from sets import Set;
 
 verbose = False
 
+def chdir(dir):
+    if os.name == 'nt':
+        os.environ['PWD']=dir
+    os.chdir(dir)
+
 def die(msg):
     if verbose:
         raise Exception(msg)
@@ -712,7 +717,7 @@ class P4Submit(Command):
         print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
         self.oldWorkingDirectory = os.getcwd()
 
-        os.chdir(self.clientPath)
+        chdir(self.clientPath)
         print "Syncronizing p4 checkout..."
         system("p4 sync ...")
 
@@ -732,7 +737,7 @@ class P4Submit(Command):
 
         if len(commits) == 0:
             print "All changes applied!"
-            os.chdir(self.oldWorkingDirectory)
+            chdir(self.oldWorkingDirectory)
 
             sync = P4Sync()
             sync.run([])
@@ -1670,7 +1675,7 @@ class P4Clone(P4Sync):
         print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
         if not os.path.exists(self.cloneDestination):
             os.makedirs(self.cloneDestination)
-        os.chdir(self.cloneDestination)
+        chdir(self.cloneDestination)
         system("git init")
         self.gitdir = os.getcwd() + "/.git"
         if not P4Sync.run(self, depotPaths):
@@ -1782,7 +1787,7 @@ def main():
                 if os.path.exists(cmd.gitdir):
                     cdup = read_pipe("git rev-parse --show-cdup").strip()
                     if len(cdup) > 0:
-                        os.chdir(cdup);
+                        chdir(cdup);
 
         if not isValidGitDir(cmd.gitdir):
             if isValidGitDir(cmd.gitdir + "/.git"):
-- 
1.6.0.rc3.11.g8134a
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help