git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add test for correct coloring of git log --decoration

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Jun 28, 2010, 07:30 UTC
Message-ID
<1277710240-11378-1-git-send-email-ayiehere@gmail.com>
In-Reply-To
<7v6314fd6q.fsf@alter.siamese.dyndns.org>
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
---
On Mon, Jun 28, 2010 at 4:11 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> * ar/decorate-color (2010-06-24) 4 commits
>  - Allow customizable commit decorations colors
>  - log --decorate: Colorize commit decorations
>  - log-tree.c: Use struct name_decoration's type for classifying decoration
>  - commit.h: add 'type' to struct name_decoration
> 
> Tests, perhaps?  Otherwise looked sane.

Here is a proposed test for checking if the decorations are colored correctly. It should be applied on top of 5e11bee65f601ba97dc4c61c75fcb2f448fdcb1c in pu.

I've tried adding 
	log --decorate --all --oneline --color=always

to t4013-diff-various.sh but it seems a bit out of place because my test only test for colors, while no other test in that file test for colors, hence the new test file (t4207-log-decoration-colors.sh).

nazri
 t/t4207-log-decoration-colors.sh |   70 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 70 insertions(+), 0 deletions(-)
 create mode 100755 t/t4207-log-decoration-colors.sh
diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh
new file mode 100755
index 0000000..260e71f
--- /dev/null
+++ b/t/t4207-log-decoration-colors.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Nazri Ramliy
+#
+
+test_description='Test for "git log --decorate" colors
+'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+  echo foo > foo.txt &&
+  git add foo.txt &&
+  test_tick &&
+  git commit -m first &&
+
+  echo bar > bar.txt &&
+  git add bar.txt &&
+  test_tick &&
+  git commit -m second &&
+
+  test_tick &&
+  EDITOR=cat git tag v1.0 &&
+
+  git clone . local_clone &&
+
+  cd local_clone &&
+  git config diff.color.commit yellow &&
+  git config color.decorate.branch green &&
+  git config color.decorate.remoteBranch red &&
+  git config color.decorate.tag yellow &&
+  git config color.decorate.stash magenta &&
+  git config color.decorate.HEAD cyan &&
+
+  echo baz >> foo.txt &&
+  git stash save baz
+'
+
+get_color()
+{
+  git config --get-color no.such.slot "$1"
+}
+
+# Colors
+c_reset=$(get_color reset)
+c_commit=$(get_color yellow)
+c_branch=$(get_color green)
+c_remoteBranch=$(get_color red)
+c_tag=$(get_color yellow)
+c_stash=$(get_color magenta)
+c_HEAD=$(get_color cyan)
+
+cat > expected << EOF
+${c_commit}COMMIT_ID (${c_stash}refs/stash${c_reset}${c_commit})${c_reset} On master: baz
+${c_commit}COMMIT_ID (${c_HEAD}HEAD${c_reset}${c_commit},\
+ ${c_tag}tag: v1.0${c_reset}${c_commit},\
+ ${c_remoteBranch}origin/master${c_reset}${c_commit},\
+ ${c_remoteBranch}origin/HEAD${c_reset}${c_commit},\
+ ${c_branch}master${c_reset}${c_commit})${c_reset} second
+${c_commit}COMMIT_ID${c_reset} first
+EOF
+
+# We want log to show all, but the second parent to refs/stash is irrelevant
+# to this test since it does not contain any decoration, hence --first-parent
+test_expect_success 'Commit Decorations Colored Correctly' '
+  git log --first-parent --abbrev=10 --all --decorate --oneline --color=always |sed "s/[0-9a-f]\{10,10\}/COMMIT_ID/" > out &&
+  test_cmp expected out
+'
+
+test_done
-- 
1.7.1.245.g7c42e.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 5 in “What's cooking in git.git (Jun 2010, #05; Sun, 27)”
  1. Junio C HamanoJun 27, 2010
  2. Add test for correct coloring of git log --decorationNazri Ramliy, Jun 28, 2010
  3. Junio C HamanoJun 29, 2010
  4. Add test for correct coloring of git log --decorationNazri Ramliy, Jun 29, 2010
  5. Junio C HamanoJun 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.