git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.
Previous: Junio C HamanoNext: Junio C Hamano
Message 17 of 18 in “blame: color line by commit”
  1. 0/2 blame: color line by commitStefan Beller, Apr 16, 2018
  2. 1/2 builtin/blame: dim uninteresting metadata linesStefan Beller, Apr 16, 2018
  3. Junio C HamanoApr 17, 2018
  4. Stefan BellerApr 17, 2018
  5. 2/2 builtin/blame: highlight recently changed linesStefan Beller, Apr 16, 2018
  6. Junio C HamanoApr 17, 2018
  7. Junio C HamanoApr 17, 2018
  8. Stefan BellerApr 17, 2018
  9. Stefan BellerApr 17, 2018
  10. 1/2 builtin/blame: dim uninteresting metadata linesStefan Beller, Apr 17, 2018
  11. 2/2 builtin/blame: highlight recently changed linesStefan Beller, Apr 17, 2018
  12. Eric SunshineApr 17, 2018
  13. Junio C HamanoApr 18, 2018
  14. René ScharfeJun 9, 2018
  15. Stefan BellerJun 11, 2018
  16. Junio C HamanoJun 14, 2018
  17. Junio C HamanoApr 18, 2018
  18. Junio C HamanoApr 18, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.