Better tattoo.
[git-central.git] / tests / t5500-script-tattoo.sh
index 7352183..bab6dd2 100644 (file)
@@ -17,61 +17,81 @@ test_expect_success 'setup' '
        git push origin stable
 '
 
-test_expect_success 'tattoo 0' '
+# tattoo makes assumptions based on the update stable hook sanity checks
+install_update_hook 'update-stable'
+
+test_expect_success 'tattoo of first commit' '
+       gc-tattoo | grep 0
+'
+
+test_expect_success 'tattoo 1' '
        git checkout -b topic1 &&
+       echo "$test_name" >a.topic1 &&
+       git add a.topic1 &&
+       git commit -a -m "move topic1-1" &&
        git push origin topic1 &&
-       gc-tattoo | grep topic1-0
+       gc-tattoo | grep topic1-1
 '
 
-test_expect_success 'tattoo 1' '
+test_expect_success 'tattoo 2' '
        echo "$test_name" >a &&
-       git commit -a -m "make topic1-1" &&
+       git commit -a -m "make topic1-2" &&
        git push origin topic1 &&
-       gc-tattoo | grep topic1-1
+       gc-tattoo | grep topic1-2
 '
 
-test_expect_success 'merge topic2 topic1 as tattoo 2' '
+test_expect_success 'merge topic2 into topic1 as tattoo 3' '
        git checkout -b topic2 stable &&
        echo "$test_name" >a.topic2 &&
-       git add a.topic2
-       git commit -m "make topic2" &&
+       git add a.topic2 &&
+       git commit -m "make topic2-1" &&
        git push origin topic2 &&
-       gc-tattoo | grep topic2-1
+       gc-tattoo | grep topic2-1 &&
 
        git checkout topic1 &&
        git merge topic2 &&
        git push origin topic1 &&
-       gc-tattoo | grep topic1-2
-'
+       gc-tattoo | grep topic1-3 &&
 
-test_expect_success 'stable without a tag' '
-       git checkout stable &&
-       head=$(git rev-parse HEAD) &&
-       gc-tattoo | grep "stable-$head"
-'
-
-test_expect_success 'stable with a tag' '
-       git tag -m "1.0" 1.0 &&
-       gc-tattoo | grep "1.0"
+       git checkout topic2 &&
+       gc-tattoo | grep topic2-1
 '
 
 test_expect_success 'fails if not pushed' '
        git checkout topic1 &&
        echo "$test_name" >a &&
-       git commit -a -m "make topic1-3" &&
-       gc-tattoo | grep "topic1 has not been pushed"
+       git commit -a -m "make topic1-4" &&
+       head=$(git rev-parse HEAD) &&
+       gc-tattoo | grep "$head has not been pushed" &&
+       git push origin topic1 &&
+       gc-tattoo | grep topic1-4
 '
 
 test_expect_success 'stable fails if not pushed' '
        git checkout stable &&
        git merge --no-ff topic1 &&
-       gc-tattoo | grep "stable has not been pushed"
+       head=$(git rev-parse HEAD) &&
+       gc-tattoo | grep "$head has not been pushed" &&
+       git push &&
+       gc-tattoo | grep "stable-$head"
+'
+
+test_expect_success 'stable without a tag' '
+       git checkout stable &&
+       head=$(git rev-parse HEAD) &&
+       gc-tattoo | grep "stable-$head"
+'
+
+test_expect_success 'stable with a tag' '
+       git tag -m "1.0" 1.0 &&
+       gc-tattoo | grep "1.0"
 '
 
 test_expect_success 'use origin stable not local' '
-       git checkout topic1 &&
-       git push origin topic1 &&
-       gc-tattoo | grep "topic1-3"
+       git checkout origin/stable &&
+       git branch -d stable &&
+       git checkout topic2 &&
+       gc-tattoo | grep "topic2-1"
 '
 
 test_done