{"thread":{"id":"19521","subject":"[PATCH] t6050: check pushing something based on a replaced commit","startedAt":"2009-05-27T05:14:09Z","lastAt":"2009-05-27T05:14:09Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"114767","messageId":"20090527051410.3789.1705.chriscool@tuxfamily.org","threadId":"19521","inReplyTo":null,"subject":"[PATCH] t6050: check pushing something based on a replaced commit","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-05-27T05:14:09Z","receivedAt":"2009-05-27T05:14:09Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"When using something like:\n\n$ git push $there 04a8c^2:master\n\nwe need to parse 04a8c to find its second parent and then start\ndiscussing what object to send with the other end.  \"04a8c^2\" is a direct\nuser input and should mean the same commit as git show \"04a8c^2\" would\ngive the user, so it obviously needs to obey the replace rules (making\n04a8c parsed), but the object transfer should not look at replace at all.\n\nThis patch adds some tests to check that the above is working well.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t6050-replace.sh |   68 ++++++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 68 insertions(+), 0 deletions(-)\n\n\tMaybe I am missing something but it looks like replacing\n\tan object directly listed on the command line works.\n\tAnd this means that we don't need to unparse commits.\n\ndiff --git a/t/t6050-replace.sh b/t/t6050-replace.sh\nindex 448a19a..8b8bd81 100755\n--- a/t/t6050-replace.sh\n+++ b/t/t6050-replace.sh\n@@ -127,6 +127,74 @@ test_expect_success '\"git replace\" replacing' '\n      test \"$HASH2\" = \"$(git replace)\"\n '\n \n+# This creates a side branch where the bug in H2\n+# does not appear because P2 is created by applying\n+# H2 and squashing H5 into it.\n+# P3, P4 and P6 are created by cherry-picking H3, H4\n+# and H6 respectively.\n+#\n+# At this point, we should have the following:\n+#\n+#    P2--P3--P4--P6\n+#   /\n+# H1-H2-H3-H4-H5-H6-H7\n+#\n+# Then we replace H6 with P6.\n+#\n+test_expect_success 'create parallel branch without the bug' '\n+     git replace -d $HASH2 &&\n+     git show $HASH2 | grep \"A U Thor\" &&\n+     git checkout $HASH1 &&\n+     git cherry-pick $HASH2 &&\n+     git show $HASH5 | git apply &&\n+     git commit --amend -m \"hello: 4 more lines WITHOUT the bug\" hello &&\n+     PARA2=$(git rev-parse --verify HEAD) &&\n+     git cherry-pick $HASH3 &&\n+     PARA3=$(git rev-parse --verify HEAD) &&\n+     git cherry-pick $HASH4 &&\n+     PARA4=$(git rev-parse --verify HEAD) &&\n+     git cherry-pick $HASH6 &&\n+     PARA6=$(git rev-parse --verify HEAD) &&\n+     git replace $HASH6 $PARA6 &&\n+     git checkout master &&\n+     cur=$(git rev-parse --verify HEAD) &&\n+     test \"$cur\" = \"$HASH7\" &&\n+     git log --pretty=oneline | grep $PARA2 &&\n+     git remote add cloned ./clone_dir\n+'\n+\n+test_expect_success 'push to cloned repo' '\n+     git push cloned $HASH6^:refs/heads/parallel &&\n+     cd clone_dir &&\n+     git checkout parallel &&\n+     git log --pretty=oneline | grep $PARA2 &&\n+     cd ..\n+'\n+\n+test_expect_success 'push branch with replacement' '\n+     git cat-file commit $PARA3 | grep \"author A U Thor\" &&\n+     S=$(git cat-file commit $PARA3 | sed -e \"s/A U/O/\" | git hash-object -t commit --stdin -w) &&\n+     git cat-file commit $S | grep \"author O Thor\" &&\n+     git replace $PARA3 $S &&\n+     git show $HASH6~2 | grep \"O Thor\" &&\n+     git show $PARA3 | grep \"O Thor\" &&\n+     git push cloned $HASH6^:refs/heads/parallel2 &&\n+     cd clone_dir &&\n+     git checkout parallel2 &&\n+     git log --pretty=oneline | grep $PARA3 &&\n+     git show $PARA3 | grep \"A U Thor\" &&\n+     cd ..\n+'\n+\n+test_expect_success 'fetch branch with replacement' '\n+     git branch tofetch $HASH6 &&\n+     cd clone_dir &&\n+     git fetch origin refs/heads/tofetch:refs/heads/parallel3\n+     git log --pretty=oneline parallel3 | grep $PARA3\n+     git show $PARA3 | grep \"A U Thor\"\n+     cd ..\n+'\n+\n #\n #\n test_done\n-- \n1.6.3.GIT\n"}]}