* [PATCH 1/4] git-p4: ensure submit clientPath exists before chdir
2011-12-09 23:48 [PATCH 0/4] git-p4: paths for p4 Pete Wyckoff
@ 2011-12-09 23:48 ` Pete Wyckoff
2011-12-09 23:48 ` [PATCH 2/4] git-p4: submit test for auto-creating clientPath Pete Wyckoff
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Pete Wyckoff @ 2011-12-09 23:48 UTC (permalink / raw)
To: git; +Cc: Gary Gibbons, Junio C Hamano
From: Gary Gibbons <ggibbons@perforce.com>
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 <ggibbons@perforce.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
contrib/fast-import/git-p4 | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index b975d67..99d3abe 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1099,6 +1099,10 @@ class P4Submit(Command, P4UserMap):
print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
self.oldWorkingDirectory = os.getcwd()
+ # ensure the clientPath exists
+ if not os.path.exists(self.clientPath):
+ os.makedirs(self.clientPath)
+
chdir(self.clientPath)
print "Synchronizing p4 checkout..."
p4_sync("...")
--
1.7.8.rc4.42.g8317d
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] git-p4: submit test for auto-creating clientPath
2011-12-09 23:48 [PATCH 0/4] git-p4: paths for p4 Pete Wyckoff
2011-12-09 23:48 ` [PATCH 1/4] git-p4: ensure submit clientPath exists before chdir Pete Wyckoff
@ 2011-12-09 23:48 ` Pete Wyckoff
2011-12-09 23:48 ` [PATCH 3/4] git-p4: use absolute directory for PWD env var Pete Wyckoff
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Pete Wyckoff @ 2011-12-09 23:48 UTC (permalink / raw)
To: git; +Cc: Gary Gibbons, Junio C Hamano
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
t/t9807-submit.sh | 38 ++++++++++++++++++++++++++++++++++++++
1 files changed, 38 insertions(+), 0 deletions(-)
create mode 100755 t/t9807-submit.sh
diff --git a/t/t9807-submit.sh b/t/t9807-submit.sh
new file mode 100755
index 0000000..85ab0d0
--- /dev/null
+++ b/t/t9807-submit.sh
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='git-p4 submit'
+
+. ./lib-git-p4.sh
+
+test_expect_success 'start p4d' '
+ start_p4d
+'
+
+test_expect_success 'init depot' '
+ (
+ cd "$cli" &&
+ echo file1 >file1 &&
+ p4 add file1 &&
+ p4 submit -d "change 1"
+ )
+'
+
+test_expect_success 'submit with no client dir' '
+ test_when_finished cleanup_git &&
+ "$GITP4" clone --dest="$git" //depot &&
+ (
+ cd "$git" &&
+ echo file2 >file2 &&
+ git add file2 &&
+ git commit -m "git commit 2" &&
+ rm -rf "$cli" &&
+ git config git-p4.skipSubmitEdit true &&
+ "$GITP4" submit
+ )
+'
+
+test_expect_success 'kill p4d' '
+ kill_p4d
+'
+
+test_done
--
1.7.8.rc4.42.g8317d
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] git-p4: use absolute directory for PWD env var
2011-12-09 23:48 [PATCH 0/4] git-p4: paths for p4 Pete Wyckoff
2011-12-09 23:48 ` [PATCH 1/4] git-p4: ensure submit clientPath exists before chdir Pete Wyckoff
2011-12-09 23:48 ` [PATCH 2/4] git-p4: submit test for auto-creating clientPath Pete Wyckoff
@ 2011-12-09 23:48 ` Pete Wyckoff
2011-12-09 23:48 ` [PATCH 4/4] git-p4: test for absolute PWD problem Pete Wyckoff
2011-12-12 5:14 ` [PATCH 0/4] git-p4: paths for p4 Junio C Hamano
4 siblings, 0 replies; 6+ messages in thread
From: Pete Wyckoff @ 2011-12-09 23:48 UTC (permalink / raw)
To: git; +Cc: Gary Gibbons, Junio C Hamano
From: Gary Gibbons <ggibbons@perforce.com>
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>
---
contrib/fast-import/git-p4 | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 99d3abe..0083f86 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:
--
1.7.8.rc4.42.g8317d
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] git-p4: test for absolute PWD problem
2011-12-09 23:48 [PATCH 0/4] git-p4: paths for p4 Pete Wyckoff
` (2 preceding siblings ...)
2011-12-09 23:48 ` [PATCH 3/4] git-p4: use absolute directory for PWD env var Pete Wyckoff
@ 2011-12-09 23:48 ` Pete Wyckoff
2011-12-12 5:14 ` [PATCH 0/4] git-p4: paths for p4 Junio C Hamano
4 siblings, 0 replies; 6+ messages in thread
From: Pete Wyckoff @ 2011-12-09 23:48 UTC (permalink / raw)
To: git; +Cc: Gary Gibbons, Junio C Hamano
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
t/t9808-chdir.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
create mode 100755 t/t9808-chdir.sh
diff --git a/t/t9808-chdir.sh b/t/t9808-chdir.sh
new file mode 100755
index 0000000..e6fd681
--- /dev/null
+++ b/t/t9808-chdir.sh
@@ -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" &&
+ echo file1 >file1 &&
+ p4 add file1 &&
+ p4 submit -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_finished cleanup_git &&
+ (
+ P4CONFIG=p4config && export P4CONFIG &&
+ unset P4PORT P4CLIENT &&
+ "$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_finished cleanup_git &&
+ (
+ P4CONFIG=p4config && export P4CONFIG &&
+ unset P4PORT P4CLIENT &&
+ "$GITP4" clone --verbose --dest="git" //depot
+ )
+'
+
+test_expect_success 'kill p4d' '
+ kill_p4d
+'
+
+test_done
--
1.7.8.rc4.42.g8317d
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/4] git-p4: paths for p4
2011-12-09 23:48 [PATCH 0/4] git-p4: paths for p4 Pete Wyckoff
` (3 preceding siblings ...)
2011-12-09 23:48 ` [PATCH 4/4] git-p4: test for absolute PWD problem Pete Wyckoff
@ 2011-12-12 5:14 ` Junio C Hamano
4 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2011-12-12 5:14 UTC (permalink / raw)
To: Pete Wyckoff; +Cc: git, Gary Gibbons
Thanks; will queue directly to 'master'.
^ permalink raw reply [flat|nested] 6+ messages in thread