{"thread":{"id":"16219","subject":"[PATCH 2/7 v3] bisect: add test cases for \"git bisect replace\"","startedAt":"2008-11-08T07:48:55Z","lastAt":"2008-11-08T07:48:55Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":3,"patchTotal":7},"messages":[{"id":"95195","messageId":"20081108084855.3fa6ae7b.chriscool@tuxfamily.org","threadId":"16219","inReplyTo":null,"subject":"[PATCH 2/7 v3] bisect: add test cases for \"git bisect replace\"","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2008-11-08T07:48:55Z","receivedAt":"2008-11-08T07:48:55Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n t/t6035-bisect-replace.sh |  130 +++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 130 insertions(+), 0 deletions(-)\n create mode 100755 t/t6035-bisect-replace.sh\n\ndiff --git a/t/t6035-bisect-replace.sh b/t/t6035-bisect-replace.sh\nnew file mode 100755\nindex 0000000..6ab3667\n--- /dev/null\n+++ b/t/t6035-bisect-replace.sh\n@@ -0,0 +1,130 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2008 Christian Couder\n+#\n+test_description='Test git bisect replace functionality'\n+\n+exec </dev/null\n+\n+. ./test-lib.sh\n+\n+add_and_commit_file()\n+{\n+    _file=\"$1\"\n+    _msg=\"$2\"\n+\n+    git add $_file || return $?\n+    test_tick || return $?\n+    git commit --quiet -m \"$_file: $_msg\"\n+}\n+\n+HASH1=\n+HASH2=\n+HASH3=\n+HASH4=\n+HASH5=\n+HASH6=\n+HASH7=\n+\n+test_expect_success 'set up buggy branch' '\n+     echo \"line 1\" >> hello &&\n+     echo \"line 2\" >> hello &&\n+     echo \"line 3\" >> hello &&\n+     echo \"line 4\" >> hello &&\n+     add_and_commit_file hello \"4 lines\" &&\n+     HASH1=$(git rev-parse --verify HEAD) &&\n+     echo \"line BUG\" >> hello &&\n+     echo \"line 6\" >> hello &&\n+     echo \"line 7\" >> hello &&\n+     echo \"line 8\" >> hello &&\n+     add_and_commit_file hello \"4 more lines with a BUG\" &&\n+     HASH2=$(git rev-parse --verify HEAD) &&\n+     echo \"line 9\" >> hello &&\n+     echo \"line 10\" >> hello &&\n+     add_and_commit_file hello \"2 more lines\" &&\n+     HASH3=$(git rev-parse --verify HEAD) &&\n+     echo \"line 11\" >> hello &&\n+     add_and_commit_file hello \"1 more line\" &&\n+     HASH4=$(git rev-parse --verify HEAD) &&\n+     sed -e \"s/BUG/5/\" hello > hello.new &&\n+     mv hello.new hello &&\n+     add_and_commit_file hello \"BUG fixed\" &&\n+     HASH5=$(git rev-parse --verify HEAD) &&\n+     echo \"line 12\" >> hello &&\n+     echo \"line 13\" >> hello &&\n+     add_and_commit_file hello \"2 more lines\" &&\n+     HASH6=$(git rev-parse --verify HEAD)\n+     echo \"line 14\" >> hello &&\n+     echo \"line 15\" >> hello &&\n+     echo \"line 16\" >> hello &&\n+     add_and_commit_file hello \"again 3 more lines\" &&\n+     HASH7=$(git rev-parse --verify HEAD)\n+'\n+\n+HASHFIX2=\n+HASHFIX3=\n+HASHFIX4=\n+\n+test_expect_success 'set up fixed branch' '\n+     git checkout $HASH1 &&\n+     echo \"line 5\" >> hello &&\n+     echo \"line 6\" >> hello &&\n+     echo \"line 7\" >> hello &&\n+     echo \"line 8\" >> hello &&\n+     add_and_commit_file hello \"4 more lines with no BUG\" &&\n+     HASHFIX2=$(git rev-parse --verify HEAD) &&\n+     git cherry-pick $HASH3 &&\n+     HASHFIX3=$(git rev-parse --verify HEAD) &&\n+     git cherry-pick $HASH4 &&\n+     HASHFIX4=$(git rev-parse --verify HEAD)\n+'\n+\n+test_expect_success '\"git bisect replace\" buggy branch with fixed one' '\n+     git bisect replace $HASH5 HEAD\n+'\n+\n+test_expect_success 'replace works when bisecting with a later bad commit' '\n+     git rev-list --bisect-all $HASH7 > rev_list.txt &&\n+     grep $HASHFIX2 rev_list.txt &&\n+     grep $HASHFIX3 rev_list.txt &&\n+     grep $HASHFIX4 rev_list.txt &&\n+     test_must_fail grep $HASH2 rev_list.txt &&\n+     test_must_fail grep $HASH3 rev_list.txt &&\n+     test_must_fail grep $HASH4 rev_list.txt\n+'\n+\n+test_expect_success 'replace works starting just after replaced commit' '\n+     git rev-list --bisect-all $HASH6 > rev_list.txt &&\n+     grep $HASHFIX2 rev_list.txt &&\n+     grep $HASHFIX3 rev_list.txt &&\n+     grep $HASHFIX4 rev_list.txt &&\n+     test_must_fail grep $HASH2 rev_list.txt &&\n+     test_must_fail grep $HASH3 rev_list.txt &&\n+     test_must_fail grep $HASH4 rev_list.txt\n+'\n+\n+test_expect_success 'replace works starting from replaced commit' '\n+     git rev-list --bisect-all $HASH5 > rev_list.txt &&\n+     grep $HASHFIX2 rev_list.txt &&\n+     grep $HASHFIX3 rev_list.txt &&\n+     grep $HASHFIX4 rev_list.txt &&\n+     test_must_fail grep $HASH2 rev_list.txt &&\n+     test_must_fail grep $HASH3 rev_list.txt &&\n+     test_must_fail grep $HASH4 rev_list.txt\n+'\n+\n+test_expect_success 'standard bisect works' '\n+     git bisect start $HASH6 $HASH1 &&\n+     test \"$(git rev-parse --verify HEAD)\" = \"$HASHFIX3\" &&\n+     git bisect good &&\n+     test \"$(git rev-parse --verify HEAD)\" = \"$HASH5\" &&\n+     git bisect bad &&\n+     test \"$(git rev-parse --verify HEAD)\" = \"$HASHFIX4\" &&\n+     git bisect bad > my_bisect_log.txt &&\n+     grep \"$HASHFIX4 is first bad commit\" my_bisect_log.txt &&\n+     git bisect reset\n+'\n+\n+#\n+#\n+test_done\n-- \n1.6.0.3.619.g9a6a\n"}]}