summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Linus Torvalds <torvalds@linux-foundation.org>2014-05-29 15:19:40 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-05-30 13:47:24 -0700
commit1571586648da4e2d759bce1146d5585c91aca8d6 (patch)
tree6ecee6879f16a55e7a38adb9eea08461608e0594
parentGit 2.0 (diff)
downloadtgif-1571586648da4e2d759bce1146d5585c91aca8d6.tar.xz
git log: support "auto" decorations
This works kind of like "--color=auto" - add decorations for interactive use, but do not change defaults when scripting or when piping the output to anything but a terminal. You can use either [log] decorate=auto in the git config files, or the "--decorate=auto" command line option to choose this behavior. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/log.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/log.c b/builtin/log.c
index 39e8836352..df6396c9c3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -63,6 +63,8 @@ static int parse_decoration_style(const char *var, const char *value)
return DECORATE_FULL_REFS;
else if (!strcmp(value, "short"))
return DECORATE_SHORT_REFS;
+ else if (!strcmp(value, "auto"))
+ return (isatty(1) || pager_in_use()) ? DECORATE_SHORT_REFS : 0;
return -1;
}