aboutsummaryrefslogtreecommitdiffstats
path: root/t/t1901-repo-structure.sh
blob: e592eea0eb3285b820b73c7b1b3bfeb710a86a19 (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
#!/bin/sh

test_description='test git repo structure'

. ./test-lib.sh

test_expect_success 'empty repository' '
	test_when_finished "rm -rf repo" &&
	git init repo &&
	(
		cd repo &&
		cat >expect <<-\EOF &&
		| Repository structure | Value |
		| -------------------- | ----- |
		| * References         |       |
		|   * Count            |     0 |
		|     * Branches       |     0 |
		|     * Tags           |     0 |
		|     * Remotes        |     0 |
		|     * Others         |     0 |
		EOF

		git repo structure >out 2>err &&

		test_cmp expect out &&
		test_line_count = 0 err
	)
'

test_expect_success 'repository with references' '
	test_when_finished "rm -rf repo" &&
	git init repo &&
	(
		cd repo &&
		git commit --allow-empty -m init &&
		git tag -a foo -m bar &&

		oid="$(git rev-parse HEAD)" &&
		git update-ref refs/remotes/origin/foo "$oid" &&

		git notes add -m foo &&

		cat >expect <<-\EOF &&
		| Repository structure | Value |
		| -------------------- | ----- |
		| * References         |       |
		|   * Count            |     4 |
		|     * Branches       |     1 |
		|     * Tags           |     1 |
		|     * Remotes        |     1 |
		|     * Others         |     1 |
		EOF

		git repo structure >out 2>err &&

		test_cmp expect out &&
		test_line_count = 0 err
	)
'

test_done