Skip to content

Commit bf1d68f

Browse files
ggibbonsgitster
authored andcommitted
git-p4: use absolute directory for PWD env var
P4 only looks at the environment variable $PWD to figure out where it is, so chdir() has code to set that every time. But when the clone --destination is not an absolute path, PWD will not be absolute and P4 won't be able to find any files expected to be in the current directory. Fix this by expanding PWD to an absolute path. One place this crops up is when using a P4CONFIG environment variable to specify P4 parameters, such as P4USER or P4PORT. Setting P4CONFIG=.p4config works for p4 invocations from the current directory. But if the value of PWD is not absolute, it fails. [ update description --pw ] Signed-off-by: Gary Gibbons <[email protected]> Signed-off-by: Pete Wyckoff <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c145225 commit bf1d68f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

contrib/fast-import/git-p4

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ def p4_build_cmd(cmd):
5353

5454
def chdir(dir):
5555
# P4 uses the PWD environment variable rather than getcwd(). Since we're
56-
# not using the shell, we have to set it ourselves.
57-
os.environ['PWD']=dir
56+
# not using the shell, we have to set it ourselves. This path could
57+
# be relative, so go there first, then figure out where we ended up.
5858
os.chdir(dir)
59+
os.environ['PWD'] = os.getcwd()
5960

6061
def die(msg):
6162
if verbose:

0 commit comments

Comments
 (0)