git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] for-each-ref: introduce %(color:...) for color
Date: Wed, 13 Nov 2013 12:01:19 -0800	[thread overview]
Message-ID: <xmqqbo1odqb4.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1384335406-16332-4-git-send-email-artagnon@gmail.com> (Ramkumar Ramachandra's message of "Wed, 13 Nov 2013 15:06:46 +0530")

Ramkumar Ramachandra <artagnon@gmail.com> writes:

> +		} else if (!prefixcmp(name, "color")) {
> +			;

How is "%(color:short)" parsed with this code?

This part says, "Yeah, I see something starting with color", and
then later strchr(name, ':') will point formatp to "short".

Luckily, "%(colorgarbage:short)" does not even come this far because
parse_atom() would not have allowed the codeflow to, but comparing
with "color:" here may be a lot more defensive and safe, I think.

And find the color-value here, stuffing v->s inside this "else if",
continue, without letting the formatp part work on refname this
piece of code does not even set.  Just like how we handle "flag"
without falling thru to the formatp code.


> +		} else if (!strcmp(name, "flag")) {
>  			char buf[256], *cp = buf;
>  			if (ref->flag & REF_ISSYMREF)
>  				cp = copy_advance(cp, ",symref");
> @@ -729,6 +732,12 @@ static void populate_value(struct refinfo *ref)
>  				else
>  					v->s = "<>";
>  				continue;
> +			} else if (!prefixcmp(name, "color")) {
> +				char color[COLOR_MAXLEN] = "";
> +
> +				color_parse(formatp, "--format", color);
> +				v->s = xstrdup(color);
> +				continue;
>  			} else
>  				die("unknown %.*s format %s",
>  				    (int)(formatp - name), name, formatp);

  reply	other threads:[~2013-11-13 20:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13  9:36 [PATCH v2 0/3] Minor f-e-r enhacements Ramkumar Ramachandra
2013-11-13  9:36 ` [PATCH v2 1/3] for-each-ref: introduce %(HEAD) asterisk marker Ramkumar Ramachandra
2013-11-13  9:36 ` [PATCH v2 2/3] for-each-ref: introduce %(upstream:track[short]) Ramkumar Ramachandra
2013-11-13 19:42   ` Junio C Hamano
2013-11-13 19:44     ` Junio C Hamano
2013-11-14  6:53     ` Ramkumar Ramachandra
2013-11-13  9:36 ` [PATCH v2 3/3] for-each-ref: introduce %(color:...) for color Ramkumar Ramachandra
2013-11-13 20:01   ` Junio C Hamano [this message]
2013-11-13 20:19     ` Junio C Hamano
2013-11-14  7:03       ` Ramkumar Ramachandra
2013-11-18 16:24         ` Junio C Hamano
2013-11-18 16:45           ` Ramkumar Ramachandra

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=xmqqbo1odqb4.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    /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).