git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git <git@vger.kernel.org>, "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: Re: [PATCH 1/2] builtin/blame: dim uninteresting metadata lines
Date: Tue, 17 Apr 2018 12:04:20 -0700	[thread overview]
Message-ID: <CAGZ79kafDRFbeUXLdjM6TpA5xzPct95PJev1rm8CMaYp2d=W5Q@mail.gmail.com> (raw)
In-Reply-To: <xmqqk1t6v7w4.fsf@gitster-ct.c.googlers.com>

Hi Junio,

>> -#define OUTPUT_SHOW_SCORE      0100
>> -#define OUTPUT_NO_AUTHOR       0200
>> +#define OUTPUT_SHOW_SCORE    0100
>> +#define OUTPUT_NO_AUTHOR     0200
>
> I wondered what these are about; they are about aligning with HT
> assuming 8-place tab stop like the other lines.

correct.

>> -#define OUTPUT_LINE_PORCELAIN 01000
>> +#define OUTPUT_LINE_PORCELAIN        01000
>
> But then this line has SP plus HT here; it should have been just a
> single HT (i.e. replace a single SP with HT), to be consistent.

fixed

>> @@ -384,6 +388,19 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
>>               char ch;
>>               int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;
>>
>> +             if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
>> +                     if (opt & OUTPUT_COLOR_LINE) {
>> +                             if (cnt > 0) {
>> +                                     color = repeated_meta_color;
>> +                                     reset = GIT_COLOR_RESET;
>> +                             } else  {
>> +                                     color ="";
>
> You need a SP after '=' that assigns an empty string to 'color'.
>
>> +                                     reset = "";
>> +                             }
>> +                     }
>> +                     fputs(color, stdout);
>> +             }
>
> This fputs() should be hidden to the case where color is *NOT* an
> empty string, no?  In any case, it should be inside "if color-line
> is in effect" block, I would think.
>
> Users of "git annotate" would not pass the --color option, so I do
> not think the outer if () block is worth the loss of readability due
> to increased indent level.
>
> I would say that it is a job of the caller of git_config() to make
> sure color.blame.lines would not take effect when the command is
> annotate, if what you are worried about is the configuration in this
> code.

ok, so we'll have to correct these mis aligned configs before hand and
here we just go by the bits set in the flags.

>> @@ -949,8 +979,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
>>
>>       blame_coalesce(&sb);
>>
>> -     if (!(output_option & OUTPUT_PORCELAIN))
>> +     if (!(output_option & OUTPUT_PORCELAIN)) {
>>               find_alignment(&sb, &output_option);
>> +             if (!*repeated_meta_color &&
>> +                 (output_option & OUTPUT_COLOR_LINE))
>> +                     strcpy(repeated_meta_color, GIT_COLOR_DARK);
>> +     }
>
> This code does not check OUTPUT_ANNOTATE_COMPAT because it assumes
> that OUTPUT_COLOR_LINE won't be in output_option when we are working
> in annotate compatibility mode.  The deeper codepaths we saw above
> should do the same.  It should be enough to drop color-line when
> anno-compat is set, or something like that, immediately after
> reading the config and overriding them from the command line.

Makes sense.

>
>> diff --git a/color.h b/color.h
>> index cd0bcedd08..196be16058 100644
>> --- a/color.h
>> +++ b/color.h
>> @@ -30,6 +30,7 @@ struct strbuf;
>>  #define GIT_COLOR_BLUE               "\033[34m"
>>  #define GIT_COLOR_MAGENTA    "\033[35m"
>>  #define GIT_COLOR_CYAN               "\033[36m"
>> +#define GIT_COLOR_DARK               "\033[1;30m"
>>  #define GIT_COLOR_BOLD_RED   "\033[1;31m"
>>  #define GIT_COLOR_BOLD_GREEN "\033[1;32m"
>>  #define GIT_COLOR_BOLD_YELLOW        "\033[1;33m"
>
> I wonder if it is worth adding a new color only to give this a
> different default.
>
> Traditionally, we use CYAN for lines that are less interesting than
> others (e.g. hunk header), so reusing it might make the life easier
> to the users, especially because I envision that we may want to
> introduce another "logical" level to give another redirection
> between the configuration keys like color.diff.frag and
> color.blame.repeatedlines and the actual ANSI sequence like
> "\033[36m".  I.e. we update the system so that these two
> configuration keys take "uninteresting" (which is one of the
> "logical" colors) by default, and then map "uninteresting" to
> "\033[36m" at the physical level by default.  The users could then
> change the mapping from "uninteresting" to "\033[1;30m" and
> consistently modify both diff.frag and blame.repeated if they wanted
> to.  Of course, if they want them to be different, they can come up
> with a different "logical" color and split the two.  And from that
> point of view, adding new colors to the default set we have above
> will make life harder for the end users.

That is a good longer term vision. I'll switch to cyan for now.
Thanks,
Stefan

  reply	other threads:[~2018-04-17 19:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-16 22:09 [PATCH 0/2] blame: color line by commit Stefan Beller
2018-04-16 22:09 ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Stefan Beller
2018-04-17  3:17   ` Junio C Hamano
2018-04-17 19:04     ` Stefan Beller [this message]
2018-04-16 22:09 ` [PATCH 2/2] builtin/blame: highlight recently changed lines Stefan Beller
2018-04-17  3:23   ` Junio C Hamano
2018-04-17  3:29   ` Junio C Hamano
2018-04-17 19:31     ` Stefan Beller
2018-04-17 19:35       ` Stefan Beller
2018-04-17 21:30         ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Stefan Beller
2018-04-17 21:30           ` [PATCH 2/2] builtin/blame: highlight recently changed lines Stefan Beller
2018-04-17 21:54             ` Eric Sunshine
2018-04-18  0:39               ` Junio C Hamano
2018-06-09 11:26             ` René Scharfe
2018-06-11 23:56               ` Stefan Beller
2018-06-14 17:37               ` Junio C Hamano
2018-04-18  0:34           ` [PATCH 1/2] builtin/blame: dim uninteresting metadata lines Junio C Hamano
2018-04-18  0:12       ` [PATCH 2/2] builtin/blame: highlight recently changed lines Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGZ79kafDRFbeUXLdjM6TpA5xzPct95PJev1rm8CMaYp2d=W5Q@mail.gmail.com' \
    --to=sbeller@google.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).