From: Junio C Hamano <gitster@pobox.com>
To: Harry Jeffery <harry@exec64.co.uk>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] pretty: add %D format specifier
Date: Tue, 16 Sep 2014 11:37:29 -0700 [thread overview]
Message-ID: <xmqqegvb2yza.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <541875ef.6153c20a.4ef5.ffff8cbb@mx.google.com> (Harry Jeffery's message of "Tue, 16 Sep 2014 17:37:38 +0000")
Harry Jeffery <harry@exec64.co.uk> writes:
> Add a new format specifier, '%D' that is identical in behaviour to '%d',
> except that it does not include the ' (' prefix or ')' suffix provided
> by '%d'.
>
> Signed-off-by: Harry Jeffery <harry@exec64.co.uk>
Thanks.
> @@ -196,20 +198,20 @@ void format_decorations(struct strbuf *sb,
> decoration = lookup_decoration(&name_decoration, &commit->object);
> if (!decoration)
> return;
> - prefix = " (";
> + strbuf_addstr(sb, color_commit);
> + strbuf_addstr(sb, prefix);
> while (decoration) {
> - strbuf_addstr(sb, color_commit);
> - strbuf_addstr(sb, prefix);
> strbuf_addstr(sb, decorate_get_color(use_color, decoration->type));
> if (decoration->type == DECORATION_REF_TAG)
> strbuf_addstr(sb, "tag: ");
> strbuf_addstr(sb, decoration->name);
> strbuf_addstr(sb, color_reset);
> - prefix = ", ";
> + strbuf_addstr(sb, color_commit);
> + if (decoration->next)
> + strbuf_addstr(sb, separator);
> decoration = decoration->next;
> }
I was kind of found of the nice trick to use a punctuation, which
first points at the prefix " (" and then later points at the
separator ", ", to allow the code that prefixes the punctuation
before showing a new item. It is now lost.
We can restore it by doing something like this, though:
if (!decoration)
return;
while (decoration) {
strbuf_addstr(sb, prefix);
strbuf_addstr(sb, decoration->name);
prefix = separator;
decoration = decoration->next;
}
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index de0cc4a..38148c1 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -457,4 +457,15 @@ EOF
> test_cmp expected actual1
> '
>
> +test_expect_success 'clean log decoration' '
> + git log --no-walk --tags --pretty="%H %D" --decorate=full >actual &&
> + cat <<EOF >expected &&
> +$head1 tag: refs/tags/tag2
> +$head2 tag: refs/tags/message-one
> +$old_head1 tag: refs/tags/message-two
> +EOF
You could indent the here-doc if you wanted to, like this:
cat >expected <<-EOF &&
$head1 tag: ...
...
EOF
and the end result may look easier on the eyes.
> + sort actual >actual1 &&
Hmph. I actually think the part that prepares the history makes
sure that the output order of the commits is predictable by using
test_commit and test_tick. I see existing tests at the end (which
is a sign that they were added more recently than the rest of the
test script, and can indicate a careless addition) already has
"sort", but we shouldn't have to sort.
> + test_cmp expected actual1
> +'
Thanks.
next prev parent reply other threads:[~2014-09-16 18:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-16 17:37 [PATCH v3] pretty: add %D format specifier Harry Jeffery
2014-09-16 18:37 ` Junio C Hamano [this message]
2014-09-17 4:30 ` Junio C Hamano
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=xmqqegvb2yza.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=harry@exec64.co.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.