OSDN Git Service

git log: support "auto" decorations
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 29 May 2014 22:19:40 +0000 (15:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 May 2014 20:47:24 +0000 (13:47 -0700)
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>
builtin/log.c

index 39e8836..df6396c 100644 (file)
@@ -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;
 }