git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: git@vger.kernel.org, "Thomas Rast" <trast@inf.ethz.ch>,
	"Christian Stimming" <stimming@tuhh.de>,
	"Ralf Thielow" <ralf.thielow@googlemail.com>,
	"Jiang Xin" <worldhello.net@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Ævar Arnfjörð" <avarab@gmail.com>, "Jan Krüger" <jk@jk.gs>
Subject: Re: [PATCH on ab/i18n] branch: remove lego in i18n tracking info strings
Date: Fri, 04 May 2012 09:10:09 -0700	[thread overview]
Message-ID: <7vr4v0apwe.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1336050720-21200-1-git-send-email-pclouds@gmail.com> ("Nguyễn	Thái Ngọc Duy"'s message of "Thu, 3 May 2012 20:12:00 +0700")

Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:

> Pseudo html tags to to mark color, like
>  "On branch <color1>%s</color1>" is probably not a bad idea.

The output machinery needs to understand _some_ color mark-up if the
destination does not support ANSI colors natively, and there already is
such a code in compat/ for windows IIRC.  Adding yet another color mark-up
wouldn't help anybody.  I would suggest to just declare that internally we
use ANSI colors as the standard color mark-up and be done with it.

>  builtin/branch.c |   31 ++++++++++++++++++++++---------
>  1 files changed, 22 insertions(+), 9 deletions(-)
>
> diff --git a/builtin/branch.c b/builtin/branch.c
> index 8813d2e..5011881 100644
> --- a/builtin/branch.c
> +++ b/builtin/branch.c
> @@ -384,6 +384,7 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
>  		int show_upstream_ref)
>  {
>  	int ours, theirs;
> +	const char *ref = NULL;
>  	struct branch *branch = branch_get(branch_name);
>  
>  	if (!stat_tracking_info(branch, &ours, &theirs)) {
> @@ -394,16 +395,28 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
>  		return;
>  	}
>  
> -	strbuf_addch(stat, '[');
>  	if (show_upstream_ref)
> -		strbuf_addf(stat, "%s: ",
> -			shorten_unambiguous_ref(branch->merge[0]->dst, 0));
> -	if (!ours)
> -		strbuf_addf(stat, _("behind %d] "), theirs);
> -	else if (!theirs)
> -		strbuf_addf(stat, _("ahead %d] "), ours);
> -	else
> -		strbuf_addf(stat, _("ahead %d, behind %d] "), ours, theirs);
> +		ref = shorten_unambiguous_ref(branch->merge[0]->dst, 0);
> +	if (!ours) {
> +		if (ref)
> +			strbuf_addf(stat, _("[%s: behind %d]"), ref, theirs);
> +		else
> +			strbuf_addf(stat, _("[behind %d]"), theirs);
> +
> +	} else if (!theirs) {
> +		if (ref)
> +			strbuf_addf(stat, _("[%s: ahead %d]"), ref, ours);
> +		else
> +			strbuf_addf(stat, _("[ahead %d]"), ours);
> +	} else {
> +		if (ref)
> +			strbuf_addf(stat, _("[%s: ahead %d, behind %d]"),
> +				    ref, ours, theirs);
> +		else
> +			strbuf_addf(stat, _("[ahead %d, behind %d]"),
> +				    ours, theirs);
> +	}
> +	strbuf_addch(stat, ' ');

You should free "ref" here, as it is an allocated piece of memory you own.

  reply	other threads:[~2012-05-04 16:10 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-02  2:45 Please pull git-po master branch Jiang Xin
2012-05-02  5:17 ` Junio C Hamano
2012-05-02  7:54 ` Thomas Rast
2012-05-02  9:13   ` Ralf Thielow
2012-05-02 13:58     ` Thomas Rast
2012-05-02 19:14       ` Ralf Thielow
2012-05-02 19:44         ` Christian Stimming
2012-05-02 13:49   ` [PATCH 0/5] de.po suggested updates Thomas Rast
2012-05-02 13:49     ` [PATCH 1/5] stash: make "saved" message translatable Thomas Rast
2012-05-02 16:42       ` Junio C Hamano
2012-05-02 13:49     ` [PATCH de.po 2/5] de.po: translate "bare" as "bloß" Thomas Rast
2012-05-02 13:49     ` [PATCH de.po 3/5] de.po: hopefully uncontroversial fixes Thomas Rast
2012-05-02 13:49     ` [PATCH de.po 4/5] de.po: translate "bad" as "ungültig" ("invalid") Thomas Rast
2012-05-02 13:49     ` [PATCH de.po 5/5] de.po: collection of suggestions Thomas Rast
2012-05-02 18:36       ` Ralf Thielow
2012-05-02 19:43         ` Thomas Rast
2012-05-02 19:42       ` Christian Stimming
2012-05-03  7:42         ` Thomas Rast
2012-05-03 13:12           ` [PATCH on ab/i18n] branch: remove lego in i18n tracking info strings Nguyễn Thái Ngọc Duy
2012-05-04 16:10             ` Junio C Hamano [this message]
2012-05-06 13:06               ` Nguyen Thai Ngoc Duy
2012-05-02 17:52     ` [PATCH 0/5] de.po suggested updates Ralf Thielow
2012-05-02 19:13     ` Christian Stimming
2012-05-02 16:40   ` Please pull git-po master branch Junio C Hamano
2012-05-03  4:31     ` Jiang Xin
2012-05-03  6:47       ` Junio C Hamano
2012-05-03 10:19         ` Jiang Xin
2012-05-03  7:49       ` Thomas Rast

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vr4v0apwe.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jk@jk.gs \
    --cc=pclouds@gmail.com \
    --cc=ralf.thielow@googlemail.com \
    --cc=stimming@tuhh.de \
    --cc=trast@inf.ethz.ch \
    --cc=worldhello.net@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).