{"thread":{"id":"54264","subject":"[PATCHv3 1/2] git-p4: demonstrate `unshelve` bug","startedAt":"2020-09-20T08:49:05Z","lastAt":"2020-09-20T08:49:10Z","messageCount":3,"participants":["Luke Diamand"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"405974","messageId":"20200920084909.17794-2-luke@diamand.org","threadId":"54264","inReplyTo":"20200920084909.17794-1-luke@diamand.org","subject":"[PATCHv3 1/2] git-p4: demonstrate `unshelve` bug","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T08:49:08Z","receivedAt":"2020-09-20T08:49:05Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"`git-p4 unshelve` uses HEAD^$n to find the parent commit, which\nfails if there is an additional commit. Augment the tests to demonstrate\nthis problem.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n t/t9832-unshelve.sh | 7 +++++--\n 1 file changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh\nindex e9276c48f4..c08234bea0 100755\n--- a/t/t9832-unshelve.sh\n+++ b/t/t9832-unshelve.sh\n@@ -29,8 +29,11 @@ test_expect_success 'init depot' '\n \t)\n '\n \n+# Create an initial clone, with a commit unrelated to the P4 change\n+# on HEAD\n test_expect_success 'initial clone' '\n-\tgit p4 clone --dest=\"$git\" //depot/@all\n+\tgit p4 clone --dest=\"$git\" //depot/@all &&\n+\ttest_commit -C \"$git\" \"unrelated\"\n '\n \n test_expect_success 'create shelved changelist' '\n@@ -77,7 +80,7 @@ EOF\n \t)\n '\n \n-test_expect_success 'update shelved changelist and re-unshelve' '\n+test_expect_failure 'update shelved changelist and re-unshelve' '\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$cli\" &&\n-- \n2.28.0.762.g324f61785e\n\n"},{"id":"405975","messageId":"20200920084909.17794-1-luke@diamand.org","threadId":"54264","inReplyTo":null,"subject":"[PATCHv3 0/2] git-p4: unshelve uses HEAD^n, not HEAD~n","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T08:49:07Z","receivedAt":"2020-09-20T08:49:05Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Updated commits incorporating comments from Eric Sunshine,\nfixing indentation.\n\nLuke Diamand (2):\n  git-p4: demonstrate `unshelve` bug\n  git-p4: fix `unshelve` bug finding parent commit\n\n git-p4.py           | 2 +-\n t/t9832-unshelve.sh | 5 ++++-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\n-- \n2.28.0.762.g324f61785e\n\n"},{"id":"405976","messageId":"20200920084909.17794-3-luke@diamand.org","threadId":"54264","inReplyTo":"20200920084909.17794-2-luke@diamand.org","subject":"[PATCHv3 2/2] git-p4: fix `unshelve` bug finding parent commit","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T08:49:09Z","receivedAt":"2020-09-20T08:49:10Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"`unshelve` was using HEAD^$n to find the parent commit. This meant that\nany intervening commits between HEAD and the last git-p4 commit would\ncause the unshelve to fail.\n\ne.g.\n    123ab Local git-only commit\n    234bc Another local git-only commit\n    345cd Perforce tip revision\n\nUnshelve needs to find 345cd.\n\nUse HEAD~$n instead.\n\nReported-by: Liu Xuhui (Jackson) <Xuhui.Liu@amd.com>\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n git-p4.py           | 2 +-\n t/t9832-unshelve.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-p4.py b/git-p4.py\nindex ca79dc0900..4433ca53de 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -4237,7 +4237,7 @@ def findLastP4Revision(self, starting_point):\n         \"\"\"\n \n         for parent in (range(65535)):\n-            log = extractLogMessageFromGitCommit(\"{0}^{1}\".format(starting_point, parent))\n+            log = extractLogMessageFromGitCommit(\"{0}~{1}\".format(starting_point, parent))\n             settings = extractSettingsGitLog(log)\n             if 'change' in settings:\n                 return settings\ndiff --git a/t/t9832-unshelve.sh b/t/t9832-unshelve.sh\nindex c08234bea0..c2200a5b69 100755\n--- a/t/t9832-unshelve.sh\n+++ b/t/t9832-unshelve.sh\n@@ -80,7 +80,7 @@ EOF\n \t)\n '\n \n-test_expect_failure 'update shelved changelist and re-unshelve' '\n+test_expect_success 'update shelved changelist and re-unshelve' '\n \ttest_when_finished cleanup_git &&\n \t(\n \t\tcd \"$cli\" &&\n-- \n2.28.0.762.g324f61785e\n\n"}]}