Skip to content

Commit 4f62c2b

Browse files
committed
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 <[email protected]>
1 parent b0e621a commit 4f62c2b

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

builtin-log.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,11 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
108108
}
109109

110110
/*
111-
* defeat log.decorate configuration interacting with --pretty
111+
* defeat log.decorate configuration interacting with --pretty=raw
112112
* from the command line.
113113
*/
114-
if (!decoration_given && rev->pretty_given)
114+
if (!decoration_given && rev->pretty_given
115+
&& rev->commit_format == CMIT_FMT_RAW)
115116
decoration_style = 0;
116117

117118
if (decoration_style) {

t/t4202-log.sh

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -390,62 +390,50 @@ test_expect_success 'log --graph with merge' '
390390
test_expect_success 'log.decorate configuration' '
391391
git config --unset-all log.decorate || :
392392
393-
git log >expect.none &&
394-
git log --decorate >expect.short &&
395-
git log --decorate=full >expect.full &&
396-
git log --oneline >expect.oneline &&
393+
git log --oneline >expect.none &&
394+
git log --oneline --decorate >expect.short &&
395+
git log --oneline --decorate=full >expect.full &&
397396
398397
echo "[log] decorate" >>.git/config &&
399-
git log >actual &&
400-
test_cmp expect.short actual &&
401398
git log --oneline >actual &&
402-
test_cmp expect.oneline actual &&
399+
test_cmp expect.short actual &&
403400
404401
git config --unset-all log.decorate &&
405402
git config log.decorate true &&
406-
git log >actual &&
403+
git log --oneline >actual &&
407404
test_cmp expect.short actual &&
408-
git log --decorate=full >actual &&
405+
git log --oneline --decorate=full >actual &&
409406
test_cmp expect.full actual &&
410-
git log --decorate=no >actual &&
407+
git log --oneline --decorate=no >actual &&
411408
test_cmp expect.none actual &&
412-
git log --oneline >actual &&
413-
test_cmp expect.oneline actual &&
414409
415410
git config --unset-all log.decorate &&
416411
git config log.decorate no &&
417-
git log >actual &&
412+
git log --oneline >actual &&
418413
test_cmp expect.none actual &&
419-
git log --decorate >actual &&
414+
git log --oneline --decorate >actual &&
420415
test_cmp expect.short actual &&
421-
git log --decorate=full >actual &&
416+
git log --oneline --decorate=full >actual &&
422417
test_cmp expect.full actual &&
423-
git log --oneline >actual &&
424-
test_cmp expect.oneline actual &&
425418
426419
git config --unset-all log.decorate &&
427420
git config log.decorate short &&
428-
git log >actual &&
421+
git log --oneline >actual &&
429422
test_cmp expect.short actual &&
430-
git log --no-decorate >actual &&
423+
git log --oneline --no-decorate >actual &&
431424
test_cmp expect.none actual &&
432-
git log --decorate=full >actual &&
425+
git log --oneline --decorate=full >actual &&
433426
test_cmp expect.full actual &&
434-
git log --oneline >actual &&
435-
test_cmp expect.oneline actual &&
436427
437428
git config --unset-all log.decorate &&
438429
git config log.decorate full &&
439-
git log >actual &&
430+
git log --oneline >actual &&
440431
test_cmp expect.full actual &&
441-
git log --no-decorate >actual &&
432+
git log --oneline --no-decorate >actual &&
442433
test_cmp expect.none actual &&
443-
git log --decorate >actual &&
434+
git log --oneline --decorate >actual &&
444435
test_cmp expect.short actual
445-
git log --oneline >actual &&
446-
test_cmp expect.oneline actual &&
447436
448-
:
449437
'
450438

451439
test_done

0 commit comments

Comments
 (0)