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