summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8a3d203)
raw | patch | inline | side by side (parent: 8a3d203)
author | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Apr 2010 21:48:55 +0000 (14:48 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 6 Apr 2010 21:49:33 +0000 (14:49 -0700) |
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 <gitster@pobox.com>
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 <gitster@pobox.com>
builtin-log.c | patch | blob | history | |
t/t4202-log.sh | patch | blob | history |
diff --git a/builtin-log.c b/builtin-log.c
index 0afba31c1fc830c021f9a08f9c0442df58cdc6ff..7f4186f19e241ce28ae57f49f3b64da731fab74a 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
struct rev_info *rev)
{
int i;
+ int decoration_given = 0;
rev->abbrev = DEFAULT_ABBREV;
rev->commit_format = CMIT_FMT_DEFAULT;
const char *arg = argv[i];
if (!strcmp(arg, "--decorate")) {
decoration_style = DECORATE_SHORT_REFS;
+ decoration_given = 1;
} else if (!prefixcmp(arg, "--decorate=")) {
const char *v = skip_prefix(arg, "--decorate=");
decoration_style = parse_decoration_style(arg, v);
if (decoration_style < 0)
die("invalid --decorate option: %s", arg);
+ decoration_given = 1;
} else if (!strcmp(arg, "--no-decorate")) {
decoration_style = 0;
} else if (!strcmp(arg, "--source")) {
} else
die("unrecognized argument: %s", arg);
}
+
+ /*
+ * defeat log.decorate configuration interacting with --pretty
+ * from the command line.
+ */
+ if (!decoration_given && rev->pretty_given)
+ decoration_style = 0;
+
if (decoration_style) {
rev->show_decorations = 1;
load_ref_decorations(decoration_style);
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 2230e606edea0c4f3dcd0b6b99298074d5341e4a..166de4479c1e704990886003f3602aaa5e13e985 100755 (executable)
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
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