Skip to content

Commit

Permalink
git-p4: chdir now properly sets PWD environment variable in msysGit
Browse files Browse the repository at this point in the history
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 <rob.blum@gmail.com>
Acked-by: Simon Hausmann <simon@lst.de>
Acked-by: Han-Wen Nienhuys <hanwen@xs4all.nl>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Robert Blum authored and Junio C Hamano committed Aug 17, 2008
1 parent 9b752a6 commit 053fd0c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ...")

Expand All @@ -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([])
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"):
Expand Down

0 comments on commit 053fd0c

Please sign in to comment.