Skip to content

Commit 053fd0c

Browse files
Robert Blumgitster
authored andcommitted
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 <[email protected]> Acked-by: Simon Hausmann <[email protected]> Acked-by: Han-Wen Nienhuys <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9b752a6 commit 053fd0c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

contrib/fast-import/git-p4

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ from sets import Set;
1616

1717
verbose = False
1818

19+
def chdir(dir):
20+
if os.name == 'nt':
21+
os.environ['PWD']=dir
22+
os.chdir(dir)
23+
1924
def die(msg):
2025
if verbose:
2126
raise Exception(msg)
@@ -712,7 +717,7 @@ class P4Submit(Command):
712717
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
713718
self.oldWorkingDirectory = os.getcwd()
714719

715-
os.chdir(self.clientPath)
720+
chdir(self.clientPath)
716721
print "Syncronizing p4 checkout..."
717722
system("p4 sync ...")
718723

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

733738
if len(commits) == 0:
734739
print "All changes applied!"
735-
os.chdir(self.oldWorkingDirectory)
740+
chdir(self.oldWorkingDirectory)
736741

737742
sync = P4Sync()
738743
sync.run([])
@@ -1670,7 +1675,7 @@ class P4Clone(P4Sync):
16701675
print "Importing from %s into %s" % (', '.join(depotPaths), self.cloneDestination)
16711676
if not os.path.exists(self.cloneDestination):
16721677
os.makedirs(self.cloneDestination)
1673-
os.chdir(self.cloneDestination)
1678+
chdir(self.cloneDestination)
16741679
system("git init")
16751680
self.gitdir = os.getcwd() + "/.git"
16761681
if not P4Sync.run(self, depotPaths):
@@ -1782,7 +1787,7 @@ def main():
17821787
if os.path.exists(cmd.gitdir):
17831788
cdup = read_pipe("git rev-parse --show-cdup").strip()
17841789
if len(cdup) > 0:
1785-
os.chdir(cdup);
1790+
chdir(cdup);
17861791

17871792
if not isValidGitDir(cmd.gitdir):
17881793
if isValidGitDir(cmd.gitdir + "/.git"):

0 commit comments

Comments
 (0)