git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Derrick Stolee <stolee@gmail.com>
Cc: issac.trotts@gmail.com, git@vger.kernel.org,
	noemi@sourcegraph.com, Issac Trotts <issactrotts@google.com>
Subject: Re: [PATCH] log: add %S option (like --source) to log --format
Date: Fri, 28 Dec 2018 10:14:21 -0800	[thread overview]
Message-ID: <xmqqd0plplhe.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <5dfd92d1-2e87-3006-1630-a33794b6066b@gmail.com> (Derrick Stolee's message of "Thu, 27 Dec 2018 08:20:32 -0500")

Derrick Stolee <stolee@gmail.com> writes:

>> +++ b/Documentation/pretty-formats.txt
>> @@ -134,6 +134,8 @@ The placeholders are:
>>   - '%cI': committer date, strict ISO 8601 format
>>   - '%d': ref names, like the --decorate option of linkgit:git-log[1]
>>   - '%D': ref names without the " (", ")" wrapping.
>> +- '%S': ref name given on the command line by which the commit was reached
>> +  (like `git log --source`), only works with `git log`
>
> This "only works with `git log`" made me think about what would happen
> with `git rev-list --pretty=format:"%h %S"` and the answer (on my
> machine) was a segfault.

That's a bad one X-<.

>> +		slot = revision_sources_at(c->pretty_ctx->rev->sources, commit);
>> +		if (slot && *slot) {
> I'm not sure this check for 'slot' being non-null is necessary, as we
> would already get a failure in the commit-slab code (for
> revision_sources_at()) if the slab is not initialized.
>> +			strbuf_addstr(sb, *slot);
>> +			return 1;
>> +		} else {
>> +			die(_("failed to get info for %%S"));
>
> Here, you die() when you fail to get a slot but above you return 0
> when the sources are not initialized.
>
> I don't see another use of die() in this method. Is that the right way
> to handle failure here? (I'm legitimately asking because I have
> over-used 'die()' in the past and am still unclear on when it is
> appropriate.)

This is definitely a bad one, too.  If '%d' cannot find decoration,
it would not "die".

Thanks.

  reply	other threads:[~2018-12-28 18:14 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19  8:33 [PATCH] log: add %S option (like --source) to log --format issac.trotts
2018-12-21  5:24 ` Issac Trotts
2018-12-22 22:22   ` Jeff King
2018-12-25  2:12     ` Issac Trotts
2018-12-27 13:20 ` Derrick Stolee
2018-12-28 18:14   ` Junio C Hamano [this message]
2018-12-31  4:35   ` Issac Trotts
  -- strict thread matches above, loose matches on Subject: below --
2019-01-11  6:30 issac.trotts
2019-01-08 13:20 issac.trotts
2019-01-08 22:21 ` Junio C Hamano
2019-01-11  6:28   ` Issac Trotts
2019-01-11 17:37     ` Junio C Hamano
2019-01-11 17:47     ` Junio C Hamano
2018-12-31 21:48 issac.trotts
2018-12-31  4:53 issac.trotts
2019-01-02 19:33 ` Junio C Hamano
2019-01-08 13:14   ` Issac Trotts
2018-12-17  6:25 Issac Trotts
2018-12-17  9:31 ` Junio C Hamano
2018-12-18  3:35   ` Issac Trotts
2018-12-17 15:59 ` Jeff King
2018-12-18 17:14   ` Issac Trotts
2018-12-19  3:47     ` Issac Trotts
2018-12-19  8:07       ` Issac Trotts
2018-12-19 17:09         ` Issac Trotts

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqd0plplhe.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=issac.trotts@gmail.com \
    --cc=issactrotts@google.com \
    --cc=noemi@sourcegraph.com \
    --cc=stolee@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).