From: Gary Gibbons Date: Fri, 9 Dec 2011 23:48:16 +0000 (-0500) Subject: git-p4: use absolute directory for PWD env var X-Git-Tag: v1.7.9-rc0~77 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf1d68ff4c86f6d6fb3214ae9b0dc9c7ac0ff781;p=git.git 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 Signed-off-by: Pete Wyckoff Signed-off-by: Junio C Hamano --- diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4 index 122b7c286..7d8e74b6d 100755 --- a/contrib/fast-import/git-p4 +++ b/contrib/fast-import/git-p4 @@ -53,9 +53,10 @@ def p4_build_cmd(cmd): def chdir(dir): # P4 uses the PWD environment variable rather than getcwd(). Since we're - # not using the shell, we have to set it ourselves. - os.environ['PWD']=dir + # not using the shell, we have to set it ourselves. This path could + # be relative, so go there first, then figure out where we ended up. os.chdir(dir) + os.environ['PWD'] = os.getcwd() def die(msg): if verbose: