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

Re: [PATCH] Reformat "your branch has diverged..." lines to reduce line length.

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 16, 2008, 19:48 UTC
Message-ID
<7v4p6pr4ob.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<1216235967-9510-1-git-send-email-apenwarr@gmail.com>
Avery Pennarun <apenwarr@gmail.com> writes:
>  	if (!num_theirs)
> -		strbuf_addf(sb, "Your branch is ahead of the tracked%s branch '%s' "
> +		strbuf_addf(sb, "Your branch is ahead of the tracked%s branch '%s'\n"
>  			    "by %d commit%s.\n",

I wonder if a simple "s/of the tracked%s branch //" is better for this kind of thing. If the message says 'origin/master', you know it is a tracked remote branch anyway, don't you?

Too wide is bad, but too tall is worse. Some of us still work in 80x24 ;-) and I prefer to make the message succinct when possible, rather than keeping it long and spread over multiple lines.

Show 6 quoted lines
>  	else
> -		strbuf_addf(sb, "Your branch and the tracked%s branch '%s' "
> -			    "have diverged,\nand respectively "
> +		strbuf_addf(sb, "Your branch and the tracked%s branch '%s'\n"
> +			    "have diverged, and respectively "
>  			    "have %d and %d different commit(s) each.\n",

This does not make the message taller, but if we were to make the "only one side advanced" cases shorter, we would need to reword this to be consistent. Perhaps something like this would be just as easy to read and more compact?

	Your branch is ahead of 'origin/add-chickens2' by 21 commits.
        Your branch is behind 'origin/add-chickens2' by 1 commit.
        Your branch and 'origin/add-chickens2' have diverged, and have
        21 and 1 different commit(s) each, respectively.

I moved "respectively" so that the variable parts will come close to the beginning of physical line.

Previous: Avery PennarunNext: Avery Pennarun
Message 2 of 4 in “Reformat "your branch has diverged..." lines to reduce line length.”
  1. Reformat "your branch has diverged..." lines to reduce line length.Avery Pennarun, Jul 16, 2008
  2. Junio C HamanoJul 16, 2008
  3. Avery PennarunJul 16, 2008
  4. Junio C HamanoJul 16, 2008

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.