Re: [PATCH 08/15] for-each-ref: get --pretty using format_commit_message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Duy Nguyen <pclouds@xxxxxxxxx> writes:

> On Wed, Jun 5, 2013 at 4:12 AM, Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote:
>>> +Caveats:
>>> +
>>> +1. Many of the placeholders in "PRETTY FORMATS" are designed to work
>>> +   specifically on commit objects: when non-commit objects are
>>> +   supplied, those placeholders won't work.
>>
>> Should "won't work" be expanded upon? It's not clear if this means
>> that git will outright crash, or if it will abort with an appropriate
>> error message, or if the directive will be displayed as-is or removed
>> from the output.
>
> It will be displayed as-is but that's a bit inconsistent: %(unknown)
> prints error and aborts while %unknown simply produces %unknown. The
> latter is how "git log --format" does it. But I think we could make
> for-each-ref --pretty to do the former for %unknown. It'll be
> consistent with %(unknown) and we do not need to elaborate much (it's
> pretty obvious when it does not work).

The Caveat Eric is asking about talks about "what happens to a
%(field) that only makes sense for a commit when showing a ref
pointing at a non-commit?", but you are answering "what happend to a
%(invalidfield) that is not defined", aren't you?

IIRC, the reason we show literal from "log --format" is to make it
easier for the person who misspelt %placeholder to spot it in the
output, and also make it easier for the person who use %placeholder
meant for newer versions of Git with an older one.  It would be a
bit unnice to die for the latter, especially if the format string is
in a script or something.

To "log --format", all input objects are expected to be commits, so
it does not have the "what does %(authordate) give when given a blob"
issue.

But for "for-each-ref --format", it is perfectly normal that you may
feed a non-commit; it makes the mechanism unusable if you errored
out %(authordate) when showing a ref that points at a tag, doesn't
it?  Substituting an inapplicable placeholder with an empty string
would be an easies way out, unless it learns a flexible/elaborate
conditional formatting mechanism, I would think.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]