t/t3415: use && where applicable.
[git/kirr.git] / t / t4207-log-decoration-colors.sh
blobbbde31b0196ae9c5ba3da33bfdb6f8c4f9c8f4e9
1 #!/bin/sh
3 # Copyright (c) 2010 Nazri Ramliy
6 test_description='Test for "git log --decorate" colors'
8 . ./test-lib.sh
10 get_color ()
12 git config --get-color no.such.slot "$1"
15 test_expect_success setup '
16 git config diff.color.commit yellow &&
17 git config color.decorate.branch green &&
18 git config color.decorate.remoteBranch red &&
19 git config color.decorate.tag "reverse bold yellow" &&
20 git config color.decorate.stash magenta &&
21 git config color.decorate.HEAD cyan &&
23 c_reset=$(get_color reset) &&
25 c_commit=$(get_color yellow) &&
26 c_branch=$(get_color green) &&
27 c_remoteBranch=$(get_color red) &&
28 c_tag=$(get_color "reverse bold yellow") &&
29 c_stash=$(get_color magenta) &&
30 c_HEAD=$(get_color cyan) &&
32 test_commit A &&
33 git clone . other &&
35 cd other &&
36 test_commit A1
37 ) &&
39 git remote add -f other ./other &&
40 test_commit B &&
41 git tag v1.0 &&
42 echo >>A.t &&
43 git stash save Changes to A.t
46 cat >expected <<EOF
47 ${c_commit}COMMIT_ID (${c_HEAD}HEAD${c_reset}${c_commit},\
48 ${c_tag}tag: v1.0${c_reset}${c_commit},\
49 ${c_tag}tag: B${c_reset}${c_commit},\
50 ${c_branch}master${c_reset}${c_commit})${c_reset} B
51 ${c_commit}COMMIT_ID (${c_tag}tag: A1${c_reset}${c_commit},\
52 ${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1
53 ${c_commit}COMMIT_ID (${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
54 On master: Changes to A.t
55 ${c_commit}COMMIT_ID (${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
56 EOF
58 # We want log to show all, but the second parent to refs/stash is irrelevant
59 # to this test since it does not contain any decoration, hence --first-parent
60 test_expect_success 'Commit Decorations Colored Correctly' '
61 git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |
62 sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" >out &&
63 test_cmp expected out
66 test_done