{"thread":{"id":"29122","subject":"[PATCH 0/4] git-p4: paths for p4","startedAt":"2011-12-09T23:48:13Z","lastAt":"2011-12-12T05:14:11Z","messageCount":6,"participants":["Pete Wyckoff","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"180726","messageId":"1323474497-14339-1-git-send-email-pw@padd.com","threadId":"29122","inReplyTo":null,"subject":"[PATCH 0/4] git-p4: paths for p4","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-12-09T23:48:13Z","receivedAt":"2011-12-09T23:48:13Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"There are two problems associated with how we set up paths for\nuse by p4, fixed in this series.  Each fix is accompanied by\nanother patch that is the unit test.\n\nThere is a break in the sequence in the t98* patches here, but\nthat is on purpose to avoid collision with new tests from other\nin-flight patches.\n\n1-2:\n    in submit, create clientPath if it does not exist\n\n3-4:\n    in clone, make sure p4 sees an absolute path\n\nGary Gibbons (2):\n  git-p4: ensure submit clientPath exists before chdir\n  git-p4: use absolute directory for PWD env var\n\nPete Wyckoff (2):\n  git-p4: submit test for auto-creating clientPath\n  git-p4: test for absolute PWD problem\n\n contrib/fast-import/git-p4 |    9 ++++++-\n t/t9807-submit.sh          |   38 ++++++++++++++++++++++++++++++++++\n t/t9808-chdir.sh           |   49 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 94 insertions(+), 2 deletions(-)\n create mode 100755 t/t9807-submit.sh\n create mode 100755 t/t9808-chdir.sh\n\n-- \n1.7.8.rc4.42.g8317d\n"},{"id":"180727","messageId":"1323474497-14339-2-git-send-email-pw@padd.com","threadId":"29122","inReplyTo":"1323474497-14339-1-git-send-email-pw@padd.com","subject":"[PATCH 1/4] git-p4: ensure submit clientPath exists before chdir","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-12-09T23:48:14Z","receivedAt":"2011-12-09T23:48:14Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"From: Gary Gibbons <ggibbons@perforce.com>\n\nSubmitting patches back to p4 requires a p4 \"client\".  This\nis a mapping from server depot paths into a local directory.\nThe directory need not exist or be populated with files; only\nthe mapping on the server is required.  When there is no\ndirectory, make git-p4 automatically create it.\n\n[ reword description --pw ]\n\nSigned-off-by: Gary Gibbons <ggibbons@perforce.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n contrib/fast-import/git-p4 |    4 ++++\n 1 files changed, 4 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex b975d67..99d3abe 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -1099,6 +1099,10 @@ class P4Submit(Command, P4UserMap):\n         print \"Perforce checkout for depot path %s located at %s\" % (self.depotPath, self.clientPath)\n         self.oldWorkingDirectory = os.getcwd()\n \n+        # ensure the clientPath exists\n+        if not os.path.exists(self.clientPath):\n+            os.makedirs(self.clientPath)\n+\n         chdir(self.clientPath)\n         print \"Synchronizing p4 checkout...\"\n         p4_sync(\"...\")\n-- \n1.7.8.rc4.42.g8317d\n"},{"id":"180728","messageId":"1323474497-14339-3-git-send-email-pw@padd.com","threadId":"29122","inReplyTo":"1323474497-14339-1-git-send-email-pw@padd.com","subject":"[PATCH 2/4] git-p4: submit test for auto-creating clientPath","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-12-09T23:48:15Z","receivedAt":"2011-12-09T23:48:15Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9807-submit.sh |   38 ++++++++++++++++++++++++++++++++++++++\n 1 files changed, 38 insertions(+), 0 deletions(-)\n create mode 100755 t/t9807-submit.sh\n\ndiff --git a/t/t9807-submit.sh b/t/t9807-submit.sh\nnew file mode 100755\nindex 0000000..85ab0d0\n--- /dev/null\n+++ b/t/t9807-submit.sh\n@@ -0,0 +1,38 @@\n+#!/bin/sh\n+\n+test_description='git-p4 submit'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+test_expect_success 'init depot' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\techo file1 >file1 &&\n+\t\tp4 add file1 &&\n+\t\tp4 submit -d \"change 1\"\n+\t)\n+'\n+\n+test_expect_success 'submit with no client dir' '\n+\ttest_when_finished cleanup_git &&\n+        \"$GITP4\" clone --dest=\"$git\" //depot &&\n+        (\n+                cd \"$git\" &&\n+                echo file2 >file2 &&\n+                git add file2 &&\n+                git commit -m \"git commit 2\" &&\n+                rm -rf \"$cli\" &&\n+                git config git-p4.skipSubmitEdit true &&\n+                \"$GITP4\" submit\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\n-- \n1.7.8.rc4.42.g8317d\n"},{"id":"180729","messageId":"1323474497-14339-4-git-send-email-pw@padd.com","threadId":"29122","inReplyTo":"1323474497-14339-1-git-send-email-pw@padd.com","subject":"[PATCH 3/4] git-p4: use absolute directory for PWD env var","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-12-09T23:48:16Z","receivedAt":"2011-12-09T23:48:16Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"From: Gary Gibbons <ggibbons@perforce.com>\n\nP4 only looks at the environment variable $PWD to figure out\nwhere it is, so chdir() has code to set that every time.  But\nwhen the clone --destination is not an absolute path, PWD will\nnot be absolute and P4 won't be able to find any files expected\nto be in the current directory.  Fix this by expanding PWD to\nan absolute path.\n\nOne place this crops up is when using a P4CONFIG environment\nvariable to specify P4 parameters, such as P4USER or P4PORT.\nSetting P4CONFIG=.p4config works for p4 invocations from the\ncurrent directory.  But if the value of PWD is not absolute, it\nfails.\n\n[ update description --pw ]\n\nSigned-off-by: Gary Gibbons <ggibbons@perforce.com>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n contrib/fast-import/git-p4 |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 99d3abe..0083f86 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -53,9 +53,10 @@ def p4_build_cmd(cmd):\n \n def chdir(dir):\n     # P4 uses the PWD environment variable rather than getcwd(). Since we're\n-    # not using the shell, we have to set it ourselves.\n-    os.environ['PWD']=dir\n+    # not using the shell, we have to set it ourselves.  This path could\n+    # be relative, so go there first, then figure out where we ended up.\n     os.chdir(dir)\n+    os.environ['PWD'] = os.getcwd()\n \n def die(msg):\n     if verbose:\n-- \n1.7.8.rc4.42.g8317d\n"},{"id":"180730","messageId":"1323474497-14339-5-git-send-email-pw@padd.com","threadId":"29122","inReplyTo":"1323474497-14339-1-git-send-email-pw@padd.com","subject":"[PATCH 4/4] git-p4: test for absolute PWD problem","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-12-09T23:48:17Z","receivedAt":"2011-12-09T23:48:17Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9808-chdir.sh |   49 +++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 49 insertions(+), 0 deletions(-)\n create mode 100755 t/t9808-chdir.sh\n\ndiff --git a/t/t9808-chdir.sh b/t/t9808-chdir.sh\nnew file mode 100755\nindex 0000000..e6fd681\n--- /dev/null\n+++ b/t/t9808-chdir.sh\n@@ -0,0 +1,49 @@\n+#!/bin/sh\n+\n+test_description='git-p4 relative chdir'\n+\n+. ./lib-git-p4.sh\n+\n+test_expect_success 'start p4d' '\n+\tstart_p4d\n+'\n+\n+test_expect_success 'init depot' '\n+\t(\n+\t\tcd \"$cli\" &&\n+\t\techo file1 >file1 &&\n+\t\tp4 add file1 &&\n+\t\tp4 submit -d \"change 1\"\n+\t)\n+'\n+\n+# P4 reads from P4CONFIG file to find its server params, if the\n+# environment variable is set\n+test_expect_success 'P4CONFIG and absolute dir clone' '\n+\tprintf \"P4PORT=$P4PORT\\nP4CLIENT=$P4CLIENT\\n\" >p4config &&\n+\ttest_when_finished \"rm \\\"$TRASH_DIRECTORY/p4config\\\"\" &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+                P4CONFIG=p4config && export P4CONFIG &&\n+\t\tunset P4PORT P4CLIENT &&\n+\t\t\"$GITP4\" clone --verbose --dest=\"$git\" //depot\n+\t)\n+'\n+\n+# same thing, but with relative directory name, note missing $ on --dest\n+test_expect_success 'P4CONFIG and relative dir clone' '\n+\tprintf \"P4PORT=$P4PORT\\nP4CLIENT=$P4CLIENT\\n\" >p4config &&\n+\ttest_when_finished \"rm \\\"$TRASH_DIRECTORY/p4config\\\"\" &&\n+\ttest_when_finished cleanup_git &&\n+\t(\n+                P4CONFIG=p4config && export P4CONFIG &&\n+\t\tunset P4PORT P4CLIENT &&\n+\t\t\"$GITP4\" clone --verbose --dest=\"git\" //depot\n+\t)\n+'\n+\n+test_expect_success 'kill p4d' '\n+\tkill_p4d\n+'\n+\n+test_done\n-- \n1.7.8.rc4.42.g8317d\n"},{"id":"180909","messageId":"7vaa6y6vl5.fsf@alter.siamese.dyndns.org","threadId":"29122","inReplyTo":"1323474497-14339-1-git-send-email-pw@padd.com","subject":"Re: [PATCH 0/4] git-p4: paths for p4","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-12-12T05:14:11Z","receivedAt":"2011-12-12T05:14:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; will queue directly to 'master'.\n"}]}