{"thread":{"id":"54263","subject":"[PATCHv2 1/2] git-p4: demonstrate `unshelve` bug","startedAt":"2020-09-20T07:48:38Z","lastAt":"2020-09-20T08:41:04Z","messageCount":4,"participants":["Luke Diamand","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"405969","messageId":"20200920074841.17043-2-luke@diamand.org","threadId":"54263","inReplyTo":"20200920074841.17043-1-luke@diamand.org","subject":"[PATCHv2 1/2] git-p4: demonstrate `unshelve` bug","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T07:48:40Z","receivedAt":"2020-09-20T07:48:38Z","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..feda4499dd 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+    test_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.20.1.390.gb5101f9297\n\n"},{"id":"405970","messageId":"20200920074841.17043-1-luke@diamand.org","threadId":"54263","inReplyTo":null,"subject":"[PATCHv2 0/2] git-p4: unshelve uses HEAD^n, not HEAD~n","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T07:48:39Z","receivedAt":"2020-09-20T07:48:38Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Updated commits incorporating comments from Eric Sunshine.\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.20.1.390.gb5101f9297\n\n"},{"id":"405971","messageId":"20200920074841.17043-3-luke@diamand.org","threadId":"54263","inReplyTo":"20200920074841.17043-2-luke@diamand.org","subject":"[PATCHv2 2/2] git-p4: fix `unshelve` bug finding parent commit","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2020-09-20T07:48:41Z","receivedAt":"2020-09-20T07:48:42Z","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 feda4499dd..7194fb2855 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.20.1.390.gb5101f9297\n\n"},{"id":"405973","messageId":"CAPig+cQiJBC4+T3Cqg==1aNoe_DULLZ=BTQoNnygJXZvTLJu0A@mail.gmail.com","threadId":"54263","inReplyTo":"20200920074841.17043-2-luke@diamand.org","subject":"Re: [PATCHv2 1/2] git-p4: demonstrate `unshelve` bug","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2020-09-20T08:40:49Z","receivedAt":"2020-09-20T08:41:04Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Sun, Sep 20, 2020 at 3:48 AM Luke Diamand <luke@diamand.org> wrote:\n> +# Create an initial clone, with a commit unrelated to the P4 change\n> +# on HEAD\n>  test_expect_success 'initial clone' '\n> -       git p4 clone --dest=\"$git\" //depot/@all\n> +       git p4 clone --dest=\"$git\" //depot/@all &&\n> +    test_commit -C \"$git\" \"unrelated\"\n>  '\n\nThe indentation of the new line is still bad[1].\n\n[1]: https://lore.kernel.org/git/CAPig+cSx35oTR_Er-DyxqV0HZw+tDHPf1GdARfw=-2bhTz02gw@mail.gmail.com/\n"}]}