Git fork
at reftables-rust 68 lines 2.2 kB view raw
1#!/bin/sh 2 3test_description='git reflog --updateref' 4 5. ./test-lib.sh 6 7test_expect_success 'setup' ' 8 git init -b main repo && 9 ( 10 cd repo && 11 12 test_commit A && 13 test_commit B && 14 test_commit C && 15 16 git reflog HEAD >expect && 17 git reset --hard HEAD~ && 18 # Make sure that the reflog does not point to the same commit 19 # as HEAD. 20 git reflog delete HEAD@{0} && 21 git reflog HEAD >actual && 22 test_cmp expect actual 23 ) 24' 25 26test_reflog_updateref () { 27 exp=$1 28 shift 29 args="$@" 30 31 test_expect_success "get '$exp' with '$args'" ' 32 test_when_finished "rm -rf copy" && 33 cp -R repo copy && 34 35 ( 36 cd copy && 37 38 $args && 39 git rev-parse $exp >expect && 40 git rev-parse HEAD >actual && 41 42 test_cmp expect actual 43 ) 44 ' 45} 46 47test_reflog_updateref B git reflog delete --updateref HEAD@{0} 48test_reflog_updateref B git reflog delete --updateref HEAD@{1} 49test_reflog_updateref C git reflog delete --updateref main@{0} 50test_reflog_updateref B git reflog delete --updateref main@{1} 51test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{0} 52test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{1} 53test_reflog_updateref C git reflog delete --updateref --rewrite main@{0} 54test_reflog_updateref B git reflog delete --updateref --rewrite main@{1} 55test_reflog_updateref B test_must_fail git reflog expire HEAD@{0} 56test_reflog_updateref B test_must_fail git reflog expire HEAD@{1} 57test_reflog_updateref B test_must_fail git reflog expire main@{0} 58test_reflog_updateref B test_must_fail git reflog expire main@{1} 59test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{0} 60test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{1} 61test_reflog_updateref B test_must_fail git reflog expire --updateref main@{0} 62test_reflog_updateref B test_must_fail git reflog expire --updateref main@{1} 63test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{0} 64test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{1} 65test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{0} 66test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{1} 67 68test_done