]>
Commit | Line | Data |
---|---|---|
5ac15ad2 ÆAB |
1 | #!/bin/sh |
2 | ||
3 | test_description='git reflog --updateref' | |
4 | ||
5 | TEST_PASSES_SANITIZE_LEAK=true | |
6 | . ./test-lib.sh | |
7 | ||
8 | test_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 | ||
27 | test_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 | ||
48 | test_reflog_updateref B git reflog delete --updateref HEAD@{0} | |
49 | test_reflog_updateref B git reflog delete --updateref HEAD@{1} | |
50 | test_reflog_updateref C git reflog delete --updateref main@{0} | |
51 | test_reflog_updateref B git reflog delete --updateref main@{1} | |
52 | test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{0} | |
53 | test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{1} | |
54 | test_reflog_updateref C git reflog delete --updateref --rewrite main@{0} | |
55 | test_reflog_updateref B git reflog delete --updateref --rewrite main@{1} | |
56 | test_reflog_updateref B test_must_fail git reflog expire HEAD@{0} | |
57 | test_reflog_updateref B test_must_fail git reflog expire HEAD@{1} | |
58 | test_reflog_updateref B test_must_fail git reflog expire main@{0} | |
59 | test_reflog_updateref B test_must_fail git reflog expire main@{1} | |
60 | test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{0} | |
61 | test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{1} | |
62 | test_reflog_updateref B test_must_fail git reflog expire --updateref main@{0} | |
63 | test_reflog_updateref B test_must_fail git reflog expire --updateref main@{1} | |
64 | test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{0} | |
65 | test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{1} | |
66 | test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{0} | |
67 | test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{1} | |
68 | ||
69 | test_done |