]>
Commit | Line | Data |
---|---|---|
56710281 NR |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2010 Nazri Ramliy | |
4 | # | |
5 | ||
b004521a | 6 | test_description='test "git log --decorate" colors' |
56710281 | 7 | |
8f37854b | 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
10 | ||
e75d2f7f | 11 | TEST_PASSES_SANITIZE_LEAK=true |
56710281 NR |
12 | . ./test-lib.sh |
13 | ||
56710281 NR |
14 | test_expect_success setup ' |
15 | git config diff.color.commit yellow && | |
16 | git config color.decorate.branch green && | |
17 | git config color.decorate.remoteBranch red && | |
18 | git config color.decorate.tag "reverse bold yellow" && | |
19 | git config color.decorate.stash magenta && | |
5797b139 | 20 | git config color.decorate.grafted black && |
56710281 NR |
21 | git config color.decorate.HEAD cyan && |
22 | ||
097b681b | 23 | c_reset="<RESET>" && |
56710281 | 24 | |
097b681b JK |
25 | c_commit="<YELLOW>" && |
26 | c_branch="<GREEN>" && | |
27 | c_remoteBranch="<RED>" && | |
28 | c_tag="<BOLD;REVERSE;YELLOW>" && | |
29 | c_stash="<MAGENTA>" && | |
30 | c_HEAD="<CYAN>" && | |
5797b139 | 31 | c_grafted="<BLACK>" && |
56710281 NR |
32 | |
33 | test_commit A && | |
34 | git clone . other && | |
35 | ( | |
36 | cd other && | |
37 | test_commit A1 | |
38 | ) && | |
39 | ||
40 | git remote add -f other ./other && | |
41 | test_commit B && | |
42 | git tag v1.0 && | |
43 | echo >>A.t && | |
44 | git stash save Changes to A.t | |
45 | ' | |
46 | ||
b004521a DS |
47 | cmp_filtered_decorations () { |
48 | sed "s/$OID_REGEX/COMMIT_ID/" actual | test_decode_color >filtered && | |
49 | test_cmp expect filtered | |
50 | } | |
56710281 NR |
51 | |
52 | # We want log to show all, but the second parent to refs/stash is irrelevant | |
53 | # to this test since it does not contain any decoration, hence --first-parent | |
b004521a DS |
54 | test_expect_success 'commit decorations colored correctly' ' |
55 | cat >expect <<-EOF && | |
dcb347f8 AK |
56 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ |
57 | ${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ | |
58 | ${c_reset}${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \ | |
59 | ${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B | |
60 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ | |
61 | ${c_tag}tag: ${c_reset}${c_tag}A1${c_reset}${c_commit}, \ | |
b004521a | 62 | ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1 |
dcb347f8 AK |
63 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ |
64 | ${c_stash}refs/stash${c_reset}${c_commit})${c_reset} On main: Changes to A.t | |
65 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ | |
66 | ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A | |
b004521a DS |
67 | EOF |
68 | ||
69 | git log --first-parent --no-abbrev --decorate --oneline --color=always --all >actual && | |
70 | cmp_filtered_decorations | |
56710281 NR |
71 | ' |
72 | ||
5797b139 DS |
73 | test_expect_success 'test coloring with replace-objects' ' |
74 | test_when_finished rm -rf .git/refs/replace* && | |
75 | test_commit C && | |
76 | test_commit D && | |
77 | ||
78 | git replace HEAD~1 HEAD~2 && | |
79 | ||
80 | cat >expect <<-EOF && | |
dcb347f8 AK |
81 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ |
82 | ${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ | |
83 | ${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit})${c_reset} D | |
84 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ | |
85 | ${c_tag}tag: ${c_reset}${c_tag}C${c_reset}${c_commit}, \ | |
5797b139 | 86 | ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} B |
dcb347f8 AK |
87 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ |
88 | ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A | |
5797b139 DS |
89 | EOF |
90 | ||
91 | git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual && | |
92 | cmp_filtered_decorations && | |
93 | git replace -d HEAD~1 && | |
94 | ||
95 | GIT_REPLACE_REF_BASE=refs/replace2/ git replace HEAD~1 HEAD~2 && | |
96 | GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent \ | |
97 | --no-abbrev --decorate --oneline --color=always HEAD >actual && | |
98 | cmp_filtered_decorations | |
99 | ' | |
100 | ||
101 | test_expect_success 'test coloring with grafted commit' ' | |
102 | test_when_finished rm -rf .git/refs/replace* && | |
103 | ||
104 | git replace --graft HEAD HEAD~2 && | |
105 | ||
106 | cat >expect <<-EOF && | |
dcb347f8 AK |
107 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD${c_reset}\ |
108 | ${c_HEAD} -> ${c_reset}${c_branch}main${c_reset}${c_commit}, \ | |
109 | ${c_reset}${c_tag}tag: ${c_reset}${c_tag}D${c_reset}${c_commit}, \ | |
5797b139 | 110 | ${c_reset}${c_grafted}replaced${c_reset}${c_commit})${c_reset} D |
dcb347f8 AK |
111 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ |
112 | ${c_tag}tag: ${c_reset}${c_tag}v1.0${c_reset}${c_commit}, \ | |
113 | ${c_reset}${c_tag}tag: ${c_reset}${c_tag}B${c_reset}${c_commit})${c_reset} B | |
114 | ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}\ | |
115 | ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A | |
5797b139 DS |
116 | EOF |
117 | ||
118 | git log --first-parent --no-abbrev --decorate --oneline --color=always HEAD >actual && | |
119 | cmp_filtered_decorations && | |
120 | git replace -d HEAD && | |
121 | ||
122 | GIT_REPLACE_REF_BASE=refs/replace2/ git replace --graft HEAD HEAD~2 && | |
123 | GIT_REPLACE_REF_BASE=refs/replace2/ git log --first-parent \ | |
124 | --no-abbrev --decorate --oneline --color=always HEAD >actual && | |
125 | cmp_filtered_decorations | |
126 | ' | |
127 | ||
56710281 | 128 | test_done |