From: Pete Wyckoff <hidden> Date: 2016-06-15 22:52:36
There are two problems associated with how we set up paths for
use by p4, fixed in this series. Each fix is accompanied by
another patch that is the unit test.
There is a break in the sequence in the t98* patches here, but
that is on purpose to avoid collision with new tests from other
in-flight patches.
1-2:
in submit, create clientPath if it does not exist
3-4:
in clone, make sure p4 sees an absolute path
Gary Gibbons (2):
git-p4: ensure submit clientPath exists before chdir
git-p4: use absolute directory for PWD env var
Pete Wyckoff (2):
git-p4: submit test for auto-creating clientPath
git-p4: test for absolute PWD problem
contrib/fast-import/git-p4 | 9 ++++++-
t/t9807-submit.sh | 38 ++++++++++++++++++++++++++++++++++
t/t9808-chdir.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 2 deletions(-)
create mode 100755 t/t9807-submit.sh
create mode 100755 t/t9808-chdir.sh
--
1.7.8.rc4.42.g8317d
From: Pete Wyckoff <hidden> Date: 2016-06-15 22:52:36
From: Gary Gibbons <redacted>
Submitting patches back to p4 requires a p4 "client". This
is a mapping from server depot paths into a local directory.
The directory need not exist or be populated with files; only
the mapping on the server is required. When there is no
directory, make git-p4 automatically create it.
[ reword description --pw ]
Signed-off-by: Gary Gibbons <redacted>
Signed-off-by: Pete Wyckoff <redacted>
---
contrib/fast-import/git-p4 | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
From: Pete Wyckoff <hidden> Date: 2016-06-15 22:52:36
From: Gary Gibbons <redacted>
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 <redacted>
Signed-off-by: Pete Wyckoff <redacted>
---
contrib/fast-import/git-p4 | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
@@ -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:
@@ -0,0 +1,49 @@+#!/bin/sh++test_description='git-p4 relative chdir'++../lib-git-p4.sh++test_expect_success'start p4d''+start_p4d+'++test_expect_success'init depot''+(+cd"$cli"&&+echofile1>file1&&+p4addfile1&&+p4submit-d"change 1"+)+'++# P4 reads from P4CONFIG file to find its server params, if the+# environment variable is set+test_expect_success'P4CONFIG and absolute dir clone''+printf"P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n">p4config&&+test_when_finished"rm \"$TRASH_DIRECTORY/p4config\""&&+test_when_finishedcleanup_git&&+(+P4CONFIG=p4config&&exportP4CONFIG&&+unsetP4PORTP4CLIENT&&+"$GITP4"clone--verbose--dest="$git"//depot+)+'++# same thing, but with relative directory name, note missing $ on --dest+test_expect_success'P4CONFIG and relative dir clone''+printf"P4PORT=$P4PORT\nP4CLIENT=$P4CLIENT\n">p4config&&+test_when_finished"rm \"$TRASH_DIRECTORY/p4config\""&&+test_when_finishedcleanup_git&&+(+P4CONFIG=p4config&&exportP4CONFIG&&+unsetP4PORTP4CLIENT&&+"$GITP4"clone--verbose--dest="git"//depot+)+'++test_expect_success'kill p4d''+kill_p4d+'++test_done