t / t4207-log-decoration-colors.shon commit Sync with 1.8.1.1 (eacf011)
   1#!/bin/sh
   2#
   3# Copyright (c) 2010 Nazri Ramliy
   4#
   5
   6test_description='Test for "git log --decorate" colors'
   7
   8. ./test-lib.sh
   9
  10get_color ()
  11{
  12        git config --get-color no.such.slot "$1"
  13}
  14
  15test_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 &&
  22
  23        c_reset=$(get_color reset) &&
  24
  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) &&
  31
  32        test_commit A &&
  33        git clone . other &&
  34        (
  35                cd other &&
  36                test_commit A1
  37        ) &&
  38
  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
  44'
  45
  46cat >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
  56EOF
  57
  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
  60test_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
  64'
  65
  66test_done