From 8a3d203bd02bec48a02557961899d81da172fa23 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 17 Feb 2010 10:20:49 -0800 Subject: log.decorate: usability fixes The configuration is meant to suppliment --decorate command line option that can be used as a boolean to turn the feature on, so it is natural to expect [log] decorate decorate = yes to work. The original commit would segfault with the first one, and would not understand the second one. Once a user has this configuration in ~/.gitconfig, there needs to be a way to override it from the command line. Add --no-decorate option to log family and also allow --decorate=no to mean the same thing. Since we allow setting log.decorate to 'true', the command line also should accept --decorate=yes and behave accordingly. New tests in t4202 are designed to exercise the interaction between the configuration variable and the command line option that overrides it. Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 't') diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 1dc224f6fb..2230e606ed 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -387,5 +387,54 @@ test_expect_success 'log --graph with merge' ' test_cmp expect actual ' +test_expect_success 'log.decorate configuration' ' + git config --unset-all log.decorate || : + + git log --oneline >expect.none && + git log --oneline --decorate >expect.short && + git log --oneline --decorate=full >expect.full && + + echo "[log] decorate" >>.git/config && + git log --oneline >actual && + test_cmp expect.short actual && + + git config --unset-all log.decorate && + git config log.decorate true && + git log --oneline >actual && + test_cmp expect.short actual && + git log --oneline --decorate=full >actual && + test_cmp expect.full actual && + git log --oneline --decorate=no >actual && + test_cmp expect.none actual && + + git config --unset-all log.decorate && + git config log.decorate no && + git log --oneline >actual && + test_cmp expect.none actual && + git log --oneline --decorate >actual && + test_cmp expect.short actual && + git log --oneline --decorate=full >actual && + test_cmp expect.full actual && + + git config --unset-all log.decorate && + git config log.decorate short && + git log --oneline >actual && + test_cmp expect.short actual && + git log --oneline --no-decorate >actual && + test_cmp expect.none actual && + git log --oneline --decorate=full >actual && + test_cmp expect.full actual && + + git config --unset-all log.decorate && + git config log.decorate full && + git log --oneline >actual && + test_cmp expect.full actual && + git log --oneline --no-decorate >actual && + test_cmp expect.none actual && + git log --oneline --decorate >actual && + test_cmp expect.short actual + +' + test_done -- cgit v1.2.3 From 635530a2fcd4bb3714452403f341f1317ae9c9f6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 6 Apr 2010 14:48:55 -0700 Subject: log --pretty/--oneline: ignore log.decorate Many scripts, most notably gitk, rely on output from the log family of command not to be molested by random user configuration. This is especially true when --pretty=raw is given. Just like we disable notes output unless the command line explicitly asks for --show-notes, disable the decoration code unless --decorate is given explicitly from the command line and --pretty or --oneline is given. Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 't') diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 2230e606ed..166de4479c 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -390,50 +390,62 @@ test_expect_success 'log --graph with merge' ' test_expect_success 'log.decorate configuration' ' git config --unset-all log.decorate || : - git log --oneline >expect.none && - git log --oneline --decorate >expect.short && - git log --oneline --decorate=full >expect.full && + git log >expect.none && + git log --decorate >expect.short && + git log --decorate=full >expect.full && + git log --oneline >expect.oneline && echo "[log] decorate" >>.git/config && - git log --oneline >actual && + git log >actual && test_cmp expect.short actual && + git log --oneline >actual && + test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate true && - git log --oneline >actual && + git log >actual && test_cmp expect.short actual && - git log --oneline --decorate=full >actual && + git log --decorate=full >actual && test_cmp expect.full actual && - git log --oneline --decorate=no >actual && + git log --decorate=no >actual && test_cmp expect.none actual && + git log --oneline >actual && + test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate no && - git log --oneline >actual && + git log >actual && test_cmp expect.none actual && - git log --oneline --decorate >actual && + git log --decorate >actual && test_cmp expect.short actual && - git log --oneline --decorate=full >actual && + git log --decorate=full >actual && test_cmp expect.full actual && + git log --oneline >actual && + test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate short && - git log --oneline >actual && + git log >actual && test_cmp expect.short actual && - git log --oneline --no-decorate >actual && + git log --no-decorate >actual && test_cmp expect.none actual && - git log --oneline --decorate=full >actual && + git log --decorate=full >actual && test_cmp expect.full actual && + git log --oneline >actual && + test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate full && - git log --oneline >actual && + git log >actual && test_cmp expect.full actual && - git log --oneline --no-decorate >actual && + git log --no-decorate >actual && test_cmp expect.none actual && - git log --oneline --decorate >actual && + git log --decorate >actual && test_cmp expect.short actual + git log --oneline >actual && + test_cmp expect.oneline actual && + : ' test_done -- cgit v1.2.3 From 4f62c2bc577bbb85b65f3261c7fab7ef74def4cd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 8 Apr 2010 10:17:17 -0700 Subject: log.decorate: only ignore it under "log --pretty=raw" Unlike notes that are often multi-line and disrupting to be placed in many output formats, a decoration is designed to be a small token that can be tacked after an existing line of the output where a commit object name sits. Disabling log.decorate for something like "log --oneline" would defeat the purpose of the configuration. We _might_ want to change it further in the future to force scripts that do not want to be broken by random end user configurations to explicitly say "log --no-decorate", but that would be an incompatible change that needs the usual multi-release-cycle deprecation process. Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) (limited to 't') diff --git a/t/t4202-log.sh b/t/t4202-log.sh index 166de4479c..2230e606ed 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -390,62 +390,50 @@ test_expect_success 'log --graph with merge' ' test_expect_success 'log.decorate configuration' ' git config --unset-all log.decorate || : - git log >expect.none && - git log --decorate >expect.short && - git log --decorate=full >expect.full && - git log --oneline >expect.oneline && + git log --oneline >expect.none && + git log --oneline --decorate >expect.short && + git log --oneline --decorate=full >expect.full && echo "[log] decorate" >>.git/config && - git log >actual && - test_cmp expect.short actual && git log --oneline >actual && - test_cmp expect.oneline actual && + test_cmp expect.short actual && git config --unset-all log.decorate && git config log.decorate true && - git log >actual && + git log --oneline >actual && test_cmp expect.short actual && - git log --decorate=full >actual && + git log --oneline --decorate=full >actual && test_cmp expect.full actual && - git log --decorate=no >actual && + git log --oneline --decorate=no >actual && test_cmp expect.none actual && - git log --oneline >actual && - test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate no && - git log >actual && + git log --oneline >actual && test_cmp expect.none actual && - git log --decorate >actual && + git log --oneline --decorate >actual && test_cmp expect.short actual && - git log --decorate=full >actual && + git log --oneline --decorate=full >actual && test_cmp expect.full actual && - git log --oneline >actual && - test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate short && - git log >actual && + git log --oneline >actual && test_cmp expect.short actual && - git log --no-decorate >actual && + git log --oneline --no-decorate >actual && test_cmp expect.none actual && - git log --decorate=full >actual && + git log --oneline --decorate=full >actual && test_cmp expect.full actual && - git log --oneline >actual && - test_cmp expect.oneline actual && git config --unset-all log.decorate && git config log.decorate full && - git log >actual && + git log --oneline >actual && test_cmp expect.full actual && - git log --no-decorate >actual && + git log --oneline --no-decorate >actual && test_cmp expect.none actual && - git log --decorate >actual && + git log --oneline --decorate >actual && test_cmp expect.short actual - git log --oneline >actual && - test_cmp expect.oneline actual && - : ' test_done -- cgit v1.2.3