From b0e621adfd5a60b7cbe95e59f09c87f0870321cb Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 8 Apr 2010 15:42:37 -0400 Subject: [PATCH 1/2] script with rev-list instead of log Because log.decorate now shows decorations for --pretty=oneline, we must explicitly turn it off when scripting. Otherwise, users with log.decorate set will get cruft like: $ git stash Saved working directory and index state WIP on master: 2c1f7f5 (HEAD, master) commit subject Instead of adding --no-decorate to the log command line, let's just use the rev-list plumbing interface instead, which does the right thing. git-submodule has a similar call. Since it just counts the commit lines, nothing is broken, but let's switch it, too, for the sake of consistency and cleanliness. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- git-stash.sh | 2 +- git-submodule.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/git-stash.sh b/git-stash.sh index 3a0685f189..0726a4a725 100755 --- a/git-stash.sh +++ b/git-stash.sh @@ -57,7 +57,7 @@ create_stash () { # state of the base commit if b_commit=$(git rev-parse --verify HEAD) then - head=$(git log --no-color --abbrev-commit --pretty=oneline -n 1 HEAD --) + head=$(git rev-list --oneline -n 1 HEAD --) else die "You do not have the initial commit yet" fi diff --git a/git-submodule.sh b/git-submodule.sh index 664f21721c..c8d80822c2 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -643,7 +643,7 @@ cmd_summary() { range=$sha1_dst fi GIT_DIR="$name/.git" \ - git log --pretty=oneline --first-parent $range | wc -l + git rev-list --first-parent $range -- | wc -l ) total_commits=" ($(($total_commits + 0)))" ;; From 4f62c2bc577bbb85b65f3261c7fab7ef74def4cd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 8 Apr 2010 10:17:17 -0700 Subject: [PATCH 2/2] 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 --- builtin-log.c | 5 +++-- t/t4202-log.sh | 60 ++++++++++++++++++++------------------------------ 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 7f4186f19e..017fcf82ce 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -108,10 +108,11 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, } /* - * defeat log.decorate configuration interacting with --pretty + * defeat log.decorate configuration interacting with --pretty=raw * from the command line. */ - if (!decoration_given && rev->pretty_given) + if (!decoration_given && rev->pretty_given + && rev->commit_format == CMIT_FMT_RAW) decoration_style = 0; if (decoration_style) { 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 && - test_cmp expect.short actual && - git log --decorate=full >actual && - test_cmp expect.full actual && - git log --decorate=no >actual && - test_cmp expect.none actual && git log --oneline >actual && - test_cmp expect.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 >actual && - test_cmp expect.none actual && - git log --decorate >actual && - test_cmp expect.short actual && - git log --decorate=full >actual && - test_cmp expect.full actual && git log --oneline >actual && - test_cmp expect.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 >actual && - test_cmp expect.short actual && - git log --no-decorate >actual && - test_cmp expect.none actual && - git log --decorate=full >actual && - test_cmp expect.full actual && git log --oneline >actual && - test_cmp expect.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 >actual && - test_cmp expect.full actual && - git log --no-decorate >actual && - test_cmp expect.none actual && - git log --decorate >actual && - test_cmp expect.short actual git log --oneline >actual && - test_cmp expect.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