Re: [PATCH 1/2] builtin/blame: dim uninteresting metadata lines
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Apr 18, 2018, 00:34 UTC
- Message-ID
- <xmqqzi21jqt4.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <20180417213049.118995-1-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 19 quoted lines
> @@ -375,6 +378,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
> struct commit_info ci;
> char hex[GIT_MAX_HEXSZ + 1];
> int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);
> + const char *color = NULL, *reset = NULL;
>
> get_commit_info(suspect->commit, &ci, 1);
> oid_to_hex_r(hex, &suspect->commit->object.oid);
> @@ -384,6 +388,18 @@ 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_COLOR_LINE) {
> + if (cnt > 0) {
> + color = repeated_meta_color;
> + reset = GIT_COLOR_RESET;
> + } else {
> + color = "";
> + reset = "";Shouldn't these be NULL as you do not want to fputs() these when not in painting mode anyway? Which would make it consistent with ...
Show 5 quoted lines
> + } > + } > + if (color) > + fputs(color, stdout); > +
... this thing which otherwise needs to be "if (color && *color)", but if you do NULL, can be left as-is ;-)
Show 6 quoted lines
> @@ -433,6 +449,8 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
> printf(" %*d) ",
> max_digits, ent->lno + 1 + cnt);
> }
> + if (reset)
> + fputs(reset, stdout);Likewise.