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

Re: [PATCH] Colourise git-branch output

From
Junio C Hamano <junkio@cox.net>
Date
Dec 12, 2006, 18:43 UTC
Message-ID
<7vpsapuf8i.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<200612120641.52556.andyparkins@gmail.com>
Andy Parkins <andyparkins@gmail.com> writes:
> The colour parameter is "color.branch" rather than "branch.color" to
> avoid clashing with the default namespace for default branch merge
> definitions.
Very nice.
Show 25 quoted lines
>  		c = ' ';
>  		if (ref_list.list[i].kind == REF_LOCAL_BRANCH &&
> -				!strcmp(ref_list.list[i].name, head))
> +				!strcmp(ref_list.list[i].name, head)) {
>  			c = '*';
> +			color = COLOR_BRANCH_CURRENT;
> +		}
>  
>  		if (verbose) {
> -			printf("%c %-*s", c, ref_list.maxwidth,
> -			       ref_list.list[i].name);
> +			printf("%c %s%-*s%s", c,
> +					branch_get_color(color),
> +					ref_list.maxwidth,
> +					ref_list.list[i].name,
> +					branch_get_color(COLOR_BRANCH_RESET));
>  			print_ref_info(ref_list.list[i].sha1, abbrev);
>  		}
>  		else
> -			printf("%c %s\n", c, ref_list.list[i].name);
> +			printf("%c %s%s%s\n", c,
> +					branch_get_color(color),
> +					ref_list.list[i].name,
> +					branch_get_color(COLOR_BRANCH_RESET));
>  	}

Now this makes me wonder if under output coloring we would still want the two-space indent and '*' prefix.

Previous: Junio C Hamano
Message 6 of 6 in “Colourise git-branch output”
  1. Colourise git-branch outputAndy Parkins, Dec 12, 2006
  2. Johannes SixtDec 12, 2006
  3. Junio C HamanoDec 12, 2006
  4. Andy ParkinsDec 12, 2006
  5. Junio C HamanoDec 12, 2006
  6. Junio C HamanoDec 12, 2006

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.