Welcome to mirror list, hosted at ThFree Co, Russian Federation.

t1417-reflog-updateref.sh « t - git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0eb5e674bc1f0dbc688523dd3f94a5e5bb32b6d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh

test_description='git reflog --updateref'

TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh

test_expect_success 'setup' '
	git init -b main repo &&
	(
		cd repo &&

		test_commit A &&
		test_commit B &&
		test_commit C &&

		git reflog HEAD >expect &&
		git reset --hard HEAD~ &&
		# Make sure that the reflog does not point to the same commit
		# as HEAD.
		git reflog delete HEAD@{0} &&
		git reflog HEAD >actual &&
		test_cmp expect actual
	)
'

test_reflog_updateref () {
	exp=$1
	shift
	args="$@"

	test_expect_success "get '$exp' with '$args'"  '
		test_when_finished "rm -rf copy" &&
		cp -R repo copy &&

		(
			cd copy &&

			$args &&
			git rev-parse $exp >expect &&
			git rev-parse HEAD >actual &&

			test_cmp expect actual
		)
	'
}

test_reflog_updateref B git reflog delete --updateref HEAD@{0}
test_reflog_updateref B git reflog delete --updateref HEAD@{1}
test_reflog_updateref C git reflog delete --updateref main@{0}
test_reflog_updateref B git reflog delete --updateref main@{1}
test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{0}
test_reflog_updateref B git reflog delete --updateref --rewrite HEAD@{1}
test_reflog_updateref C git reflog delete --updateref --rewrite main@{0}
test_reflog_updateref B git reflog delete --updateref --rewrite main@{1}
test_reflog_updateref B test_must_fail git reflog expire  HEAD@{0}
test_reflog_updateref B test_must_fail git reflog expire  HEAD@{1}
test_reflog_updateref B test_must_fail git reflog expire  main@{0}
test_reflog_updateref B test_must_fail git reflog expire  main@{1}
test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{0}
test_reflog_updateref B test_must_fail git reflog expire --updateref HEAD@{1}
test_reflog_updateref B test_must_fail git reflog expire --updateref main@{0}
test_reflog_updateref B test_must_fail git reflog expire --updateref main@{1}
test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{0}
test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite HEAD@{1}
test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{0}
test_reflog_updateref B test_must_fail git reflog expire --updateref --rewrite main@{1}

test_done