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

Re: [PATCH] blame: add color

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 8, 2013, 15:16 UTC
Message-ID
<xmqqob6zn67d.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1381241929-23378-1-git-send-email-christopherarges@gmail.com>
Chris J Arges <christopherarges@gmail.com> writes:
> Add colorized text for git blame when color.interactive is enabled.

It does not make any sense to tie this to color.interactive at all, at least to me. The "check color.blame and if absent fall back to color.ui", which is the usual pattern, would be more appropriate.

Show 8 quoted lines
> +static char blame_colors[][COLOR_MAXLEN] = {
> +	GIT_COLOR_RESET,
> +	GIT_COLOR_NORMAL,	/* PLAIN */
> +	GIT_COLOR_YELLOW,	/* COMMIT */
> +	GIT_COLOR_BOLD,		/* NAME */
> +	GIT_COLOR_CYAN,		/* LINE */
> +	GIT_COLOR_GREEN,	/* TIME */
> +};

Unlike "git grep", where some pieces of a single line are more interesting (i.e. the exact text matching the pattern given) than others (i.e. other text on the same line), and "git diff", where some lines have different meanings from others (i.e. hunk header, deleted lines, added lines, context lines), the output from "git blame" is already columnar and it is obvious to the reader of the output that everything on the leftmost part of all lines is commit object name, without distraction of extra colours; I do not see much point in painting the output into vertical stripes of colours.

It may make more sense to assign one colour to each blame origin (i.e. <commit, path> pair), to make it clear that first five lines came from the same origin that is different from the two lines that follow, etc., showing horizontal stripes of colours. If we were to go that route, I suspect that it would be too distracting to paint the whole line (like "git diff" does for added or deleted lines). Perhaps paint only the commit object name part in different colors to show which lines form a group that came from the same origin? The way "git show-branch" paints its output might give an inspiration.

Previous: Stefan BellerNext: Chris J Arges
Message 3 of 4 in “blame: add color”
  1. blame: add colorChris J Arges, Oct 8, 2013
  2. Stefan BellerOct 8, 2013
  3. Junio C HamanoOct 8, 2013
  4. Chris J ArgesOct 8, 2013

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.