Skip to content
/ git Public
forked from git/git

Commit

Permalink
git-p4: use absolute directory for PWD env var
Browse files Browse the repository at this point in the history
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 <ggibbons@perforce.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
ggibbons authored and gitster committed Dec 12, 2011
1 parent c145225 commit bf1d68f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bf1d68f

Please sign in to comment.