{"thread":{"id":"26755","subject":"[PATCH 0/2] git-p4: sync new branch regression","startedAt":"2011-03-16T20:50:08Z","lastAt":"2011-03-16T20:53:53Z","messageCount":3,"participants":["Pete Wyckoff"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"163510","messageId":"20110316205008.GA22702@arf.padd.com","threadId":"26755","inReplyTo":null,"subject":"[PATCH 0/2] git-p4: sync new branch regression","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-03-16T20:50:08Z","receivedAt":"2011-03-16T20:50:08Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Here is another fix for e32e00d (git-p4: better message for\n\"git-p4 sync\" when not cloned, 2011-02-19).  Mike pointed out\nthat his use case breaks too.\n\nThese two patches fix it, and add two new test cases to\ncheck for future breakage.  At least we're coming up with\na good set of tests.\n\n    git-p4: fix sync new branch regression\n    git-p4: test sync new branch\n\n contrib/fast-import/git-p4 |    4 +++-\n t/t9800-git-p4.sh          |   23 +++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 1 deletions(-)\n\nThese would be good on master, beyond e32e00d that is\nin your pw/p4.  Thanks,\n\n                -- Pete\n"},{"id":"163513","messageId":"20110316205246.GA23387@arf.padd.com","threadId":"26755","inReplyTo":"20110316205008.GA22702@arf.padd.com","subject":"[PATCH 1/2] git-p4: fix sync new branch regression","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-03-16T20:52:46Z","receivedAt":"2011-03-16T20:52:46Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"e32e00d (git-p4: better message for \"git-p4 sync\" when not\ncloned, 2011-02-19) broke another use case, that of using\n\"git-p4 sync\" to import a new branch into an existing repository.\n\nRefine the fix again, on top of the fix in ac34efc.\n\nReported-by: Michael Horowitz <michael.horowitz@ieee.org>\nSigned-off-by: Pete Wyckoff <pw@padd.com>\nTested-by: Michael Horowitz <michael.horowitz@ieee.org>\n---\n contrib/fast-import/git-p4 |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 7cb479c..2eacb95 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -1763,7 +1763,9 @@ class P4Sync(Command):\n \n                 changes.sort()\n             else:\n-                if not isinstance(self, P4Clone) and not self.p4BranchesInGit:\n+                # catch \"git-p4 sync\" with no new branches, in a repo that\n+                # does not have any existing git-p4 branches\n+                if len(args) == 0 and not self.p4BranchesInGit:\n                     die(\"No remote p4 branches.  Perhaps you never did \\\"git p4 clone\\\" in here.\");\n                 if self.verbose:\n                     print \"Getting p4 changes for %s...%s\" % (', '.join(self.depotPaths),\n-- \n1.7.4.1\n"},{"id":"163514","messageId":"20110316205353.GB23387@arf.padd.com","threadId":"26755","inReplyTo":"20110316205008.GA22702@arf.padd.com","subject":"[PATCH 2/2] git-p4: test sync new branch","fromName":"Pete Wyckoff","fromEmail":"pw@padd.com","sentAt":"2011-03-16T20:53:53Z","receivedAt":"2011-03-16T20:53:53Z","isPatch":true,"sender":{"key":"pw@padd.com","avatar":null},"body":"Add two new unit tests.  One to test the feature that that\nwas added in e32e00d, and another to test the regression\nthat was fixed in the parent to this commit.\n\nSigned-off-by: Pete Wyckoff <pw@padd.com>\n---\n t/t9800-git-p4.sh |   23 +++++++++++++++++++++++\n 1 files changed, 23 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh\nindex abe7c64..a523473 100755\n--- a/t/t9800-git-p4.sh\n+++ b/t/t9800-git-p4.sh\n@@ -61,6 +61,29 @@ test_expect_success 'git-p4 clone @all' '\n \trm -rf \"$git\" && mkdir \"$git\"\n '\n \n+test_expect_success 'git-p4 sync uninitialized repo' '\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\ttest_must_fail \"$GITP4\" sync &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n+#\n+# Create a git repo by hand.  Add a commit so that HEAD is valid.\n+# Test imports a new p4 repository into a new git branch.\n+#\n+test_expect_success 'git-p4 sync new branch' '\n+\ttest_create_repo \"$git\" &&\n+\tcd \"$git\" &&\n+\ttest_commit head &&\n+\t\"$GITP4\" sync --branch=refs/remotes/p4/depot //depot@all &&\n+\tgit log --oneline p4/depot >lines &&\n+\tcat lines &&\n+\ttest_line_count = 2 lines &&\n+\tcd .. &&\n+\trm -rf \"$git\" && mkdir \"$git\"\n+'\n+\n test_expect_success 'exit when p4 fails to produce marshaled output' '\n \tbadp4dir=\"$TRASH_DIRECTORY/badp4dir\" &&\n \tmkdir -p \"$badp4dir\" &&\n-- \n1.7.4.1\n"}]}