git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
RBRobert Blum <rob.blum@gmail.com>
Date
Aug 1, 2008, 19:50 UTC
Message-ID
<bad7471c0808011250v569ffaaby9e20a5ba1f971927@mail.gmail.com>

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

Signed-off-by: Robert Blum <rob.blum@gmail.com>
---

Pushing it out to the list since I'm not entirely sure who the git-p4 owner even is. CC'ed likely suspects for ownership ;)

 contrib/fast-import/git-p4 |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 6ae0429..b4d0c65 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -16,6 +16,13 @@ from sets import Set;

 verbose = False

+if os.name == 'nt':
+    def os_chdir(dir):
+        os.environ['PWD']=dir
+        os.chdir(dir)
+else:
+    os_chdir = os.chdir
+
 def die(msg):
     if verbose:
         raise Exception(msg)
@@ -712,7 +719,7 @@ class P4Submit(Command):
         print "Perforce checkout for depot path %s located at %s" % (self.depot
Path, self.clientPath)
         self.oldWorkingDirectory = os.getcwd()

-        os.chdir(self.clientPath)
+        os_chdir(self.clientPath)
         print "Syncronizing p4 checkout..."
         system("p4 sync ...")

@@ -732,7 +739,7 @@ class P4Submit(Command):

         if len(commits) == 0:
             print "All changes applied!"
-            os.chdir(self.oldWorkingDirectory)
+            os_chdir(self.oldWorkingDirectory)

             sync = P4Sync()
             sync.run([])
@@ -1670,7 +1677,7 @@ class P4Clone(P4Sync):
         print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneD
estination)
         if not os.path.exists(self.cloneDestination):
             os.makedirs(self.cloneDestination)
-        os.chdir(self.cloneDestination)
+        os_chdir(self.cloneDestination)
         system("git init")
         self.gitdir = os.getcwd() + "/.git"
         if not P4Sync.run(self, depotPaths):
@@ -1782,7 +1789,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);
+                        os_chdir(cdup);

         if not isValidGitDir(cmd.gitdir):
             if isValidGitDir(cmd.gitdir + "/.git"):
--
1.5.5.1015.g9d258
Next: Junio C Hamano
Message 1 of 8 in “git-p4: chdir now properly sets PWD environment variable in msysGit”
  1. git-p4: chdir now properly sets PWD environment variable in msysGitRobert Blum, Aug 1, 2008
  2. Junio C HamanoAug 3, 2008
  3. Simon HausmannAug 5, 2008
  4. Han-Wen NienhuysAug 4, 2008
  5. Alex RiesenAug 5, 2008
  6. Fwd: [PATCH] git-p4: chdir now properly sets PWD environment variable in msysGitRobert Blum, Aug 4, 2008
  7. Junio C HamanoAug 16, 2008
  8. Junio C HamanoAug 16, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.