Skip to content
  • Mark Lodato's avatar
    Add an optional argument for --color options · 73e9da01
    Mark Lodato authored and Junio C Hamano's avatar Junio C Hamano committed
    
    
    Make git-branch, git-show-branch, git-grep, and all the diff-based
    programs accept an optional argument <when> for --color.  The argument
    is a colorbool: "always", "never", or "auto".  If no argument is given,
    "always" is used;  --no-color is an alias for --color=never.  This makes
    the command-line interface consistent with other GNU tools, such as `ls'
    and `grep', and with the git-config color options.  Note that, without
    an argument, --color and --no-color work exactly as before.
    
    To implement this, two internal changes were made:
    
    1. Allow the first argument of git_config_colorbool() to be NULL,
       in which case it returns -1 if the argument isn't "always", "never",
       or "auto".
    
    2. Add OPT_COLOR_FLAG(), OPT__COLOR(), and parse_opt_color_flag_cb()
       to the option parsing library.  The callback uses
       git_config_colorbool(), so color.h is now a dependency
       of parse-options.c.
    
    Signed-off-by: default avatarMark Lodato <lodatom@gmail.com>
    Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    73e9da01