]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4207-log-decoration-colors.sh
clone: allow "--bare" with "-o"
[thirdparty/git.git] / t / t4207-log-decoration-colors.sh
1 #!/bin/sh
2 #
3 # Copyright (c) 2010 Nazri Ramliy
4 #
5
6 test_description='Test for "git log --decorate" colors'
7
8 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
9 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10
11 TEST_PASSES_SANITIZE_LEAK=true
12 . ./test-lib.sh
13
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 &&
20 git config color.decorate.HEAD cyan &&
21
22 c_reset="<RESET>" &&
23
24 c_commit="<YELLOW>" &&
25 c_branch="<GREEN>" &&
26 c_remoteBranch="<RED>" &&
27 c_tag="<BOLD;REVERSE;YELLOW>" &&
28 c_stash="<MAGENTA>" &&
29 c_HEAD="<CYAN>" &&
30
31 test_commit A &&
32 git clone . other &&
33 (
34 cd other &&
35 test_commit A1
36 ) &&
37
38 git remote add -f other ./other &&
39 test_commit B &&
40 git tag v1.0 &&
41 echo >>A.t &&
42 git stash save Changes to A.t
43 '
44
45 cat >expected <<EOF
46 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_HEAD}HEAD ->\
47 ${c_reset}${c_branch}main${c_reset}${c_commit},\
48 ${c_reset}${c_tag}tag: v1.0${c_reset}${c_commit},\
49 ${c_reset}${c_tag}tag: B${c_reset}${c_commit})${c_reset} B
50 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A1${c_reset}${c_commit},\
51 ${c_reset}${c_remoteBranch}other/main${c_reset}${c_commit})${c_reset} A1
52 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
53 On main: Changes to A.t
54 ${c_commit}COMMIT_ID${c_reset}${c_commit} (${c_reset}${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
55 EOF
56
57 # We want log to show all, but the second parent to refs/stash is irrelevant
58 # to this test since it does not contain any decoration, hence --first-parent
59 test_expect_success 'Commit Decorations Colored Correctly' '
60 git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |
61 sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" |
62 test_decode_color >out &&
63 test_cmp expected out
64 '
65
66 test_done