From: Nazri Ramliy <ayiehere@gmail.com>
To: gitster@pobox.com, git@vger.kernel.org
Cc: Nazri Ramliy <ayiehere@gmail.com>
Subject: [PATCH] Add test for correct coloring of git log --decoration
Date: Tue, 29 Jun 2010 15:47:08 +0800 [thread overview]
Message-ID: <1277797628-32466-1-git-send-email-ayiehere@gmail.com> (raw)
In-Reply-To: <7vbpaucs2c.fsf@alter.siamese.dyndns.org>
Signed-off-by: Nazri Ramliy <ayiehere@gmail.com>
---
On Tue, Jun 29, 2010 at 1:43 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Let's not expand a single-line description needlessly into a multi-line
> one.
Fixed.
>> +test_expect_success setup '
>> + echo foo > foo.txt &&
>
> Indent these with <TAB>, like:
>
> echo foo >foo.txt &&
Fixed.
> I think "EDITOR=cat" is doubly wrong.
Fixed.
> Do not chdir around inside test scripts without having that in a subshell,
> as people typically write "cd .." at the very end of a && chain, which may
> not be called when anything in between fails, throwing the later tests
> into chaos.
Fixed.
> In this case your excuse will be that you will run everything after this
> point in that local-clone subdirectory, but still this is not a good style
> we would want to keep around, risking to be copied by other people who do
> not think carefully.
[snip]
> I think the set-up sequence for this test script should probably be
> structured like this:
[snip]
> so that the main test is done inside the top-level directory (you wanted
> the clone only because you wanted to have remote tracking branches, not
> because you didn't want to touch the top-level directory).
Thanks for taking the time to explain it well.
I should have familiarized myself more with the utility functions in
test-lib.sh (so that I would know about test_commit).
I've updated the test to also test for the need to print 'reset' right before
restoring the commit color. This is done by setting the tag color to "reverse
bold yellow". Without the 'reset', the next decoration would be wrongly
printed in reverse.
nazri
t/t4207-log-decoration-colors.sh | 65 ++++++++++++++++++++++++++++++++++++++
1 files changed, 65 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..5ea5865
--- /dev/null
+++ b/t/t4207-log-decoration-colors.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Copyright (c) 2010 Nazri Ramliy
+#
+
+test_description='Test for "git log --decorate" colors'
+
+. ./test-lib.sh
+
+get_color ()
+{
+ git config --get-color no.such.slot "$1"
+}
+
+test_expect_success setup '
+ git config diff.color.commit yellow &&
+ git config color.decorate.branch green &&
+ git config color.decorate.remoteBranch red &&
+ git config color.decorate.tag "reverse bold yellow" &&
+ git config color.decorate.stash magenta &&
+ git config color.decorate.HEAD cyan &&
+
+ c_reset=$(get_color reset) &&
+
+ c_commit=$(get_color yellow) &&
+ c_branch=$(get_color green) &&
+ c_remoteBranch=$(get_color red) &&
+ c_tag=$(get_color "reverse bold yellow") &&
+ c_stash=$(get_color magenta) &&
+ c_HEAD=$(get_color cyan) &&
+
+ test_commit A &&
+ git clone . other &&
+ (
+ cd other &&
+ test_commit A1
+ ) &&
+
+ git remote add -f other ./other &&
+ test_commit B &&
+ git tag v1.0 &&
+ echo >>A.t &&
+ git stash save Changes to A.t
+'
+
+cat > expected << EOF
+${c_commit}COMMIT_ID (${c_HEAD}HEAD${c_reset}${c_commit},\
+ ${c_tag}tag: v1.0${c_reset}${c_commit},\
+ ${c_tag}tag: B${c_reset}${c_commit},\
+ ${c_branch}master${c_reset}${c_commit})${c_reset} B
+${c_commit}COMMIT_ID (${c_tag}tag: A1${c_reset}${c_commit},\
+ ${c_remoteBranch}other/master${c_reset}${c_commit})${c_reset} A1
+${c_commit}COMMIT_ID (${c_stash}refs/stash${c_reset}${c_commit})${c_reset}\
+ On master: Changes to A.t
+${c_commit}COMMIT_ID (${c_tag}tag: A${c_reset}${c_commit})${c_reset} A
+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
next prev parent reply other threads:[~2010-06-29 7:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-27 20:11 What's cooking in git.git (Jun 2010, #05; Sun, 27) Junio C Hamano
2010-06-28 7:30 ` [PATCH] Add test for correct coloring of git log --decoration Nazri Ramliy
2010-06-29 5:43 ` Junio C Hamano
2010-06-29 7:47 ` Nazri Ramliy [this message]
2010-06-30 20:37 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277797628-32466-1-git-send-email-ayiehere@gmail.com \
--to=ayiehere@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).