<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/trailer.c, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-01-29T18:03:32Z</updated>
<entry>
<title>pretty: add support for separator option in %(trailers)</title>
<updated>2019-01-29T18:03:32Z</updated>
<author>
<name>Anders Waldenborg</name>
<email>anders@0x63.nu</email>
</author>
<published>2019-01-28T21:33:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0b691d8685131c2c10e1a2cf2acc9b8920c5365f'/>
<id>urn:sha1:0b691d8685131c2c10e1a2cf2acc9b8920c5365f</id>
<content type='text'>
By default trailer lines are terminated by linebreaks ('\n'). By
specifying the new 'separator' option they will instead be separated by
user provided string and have separator semantics rather than terminator
semantics. The separator string can contain the literal formatting codes
%n and %xNN allowing it to be things that are otherwise hard to type
such as %x00, or comma and end-parenthesis which would break parsing.

E.g:
 $ git log --pretty='%(trailers:key=Reviewed-by,valueonly,separator=%x00)'

Signed-off-by: Anders Waldenborg &lt;anders@0x63.nu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: add support for "valueonly" option in %(trailers)</title>
<updated>2019-01-29T18:03:32Z</updated>
<author>
<name>Anders Waldenborg</name>
<email>anders@0x63.nu</email>
</author>
<published>2019-01-28T21:33:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d9b936db5226ed4b87d42a2c91324adc50c768b6'/>
<id>urn:sha1:d9b936db5226ed4b87d42a2c91324adc50c768b6</id>
<content type='text'>
With the new "key=" option to %(trailers) it often makes little sense to
show the key, as it by definition already is knows which trailer is
printed there. This new "valueonly" option makes it omit the key when
printing trailers.

E.g.:
 $ git show -s --pretty='%s%n%(trailers:key=Signed-off-by,valueonly)' aaaa88182
will show:
 &gt; upload-pack: fix broken if/else chain in config callback
 &gt; Jeff King &lt;peff@peff.net&gt;
 &gt; Junio C Hamano &lt;gitster@pobox.com&gt;

Signed-off-by: Anders Waldenborg &lt;anders@0x63.nu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: allow showing specific trailers</title>
<updated>2019-01-29T18:03:32Z</updated>
<author>
<name>Anders Waldenborg</name>
<email>anders@0x63.nu</email>
</author>
<published>2019-01-28T21:33:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=250bea0c1652ad546cd0455852bd734e4820ec46'/>
<id>urn:sha1:250bea0c1652ad546cd0455852bd734e4820ec46</id>
<content type='text'>
Adds a new "key=X" option to "%(trailers)" which will cause it to only
print trailer lines which match any of the specified keys.

Signed-off-by: Anders Waldenborg &lt;anders@0x63.nu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>interpret-trailers: allow suppressing "---" divider</title>
<updated>2018-08-23T17:08:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-23T00:49:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1688c9a4894df517241026c7a3848bdc84607986'/>
<id>urn:sha1:1688c9a4894df517241026c7a3848bdc84607986</id>
<content type='text'>
Even with the newly-tightened "---" parser, it's still
possible for a commit message to trigger a false positive if
it contains something like "--- foo". If the caller knows
that it has only a single commit message, it can now tell us
with the "--no-divider" option, eliminating any false
positives.

If we were designing this from scratch, I'd probably make
this the default. But we've advertised the "---" behavior in
the documentation since interpret-trailers has existed.
Since it's meant to be scripted, breaking that would be a
bad idea.

Note that the logic is in the underlying trailer.c code,
which is used elsewhere. The default there will keep the
current behavior, but many callers will benefit from setting
this new option. That's left for future patches.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>interpret-trailers: tighten check for "---" patch boundary</title>
<updated>2018-08-23T17:08:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-23T00:48:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c188668e387509565237a865a1c63e890f6bbcd7'/>
<id>urn:sha1:c188668e387509565237a865a1c63e890f6bbcd7</id>
<content type='text'>
The interpret-trailers command accepts not only raw commit
messages, but it also can manipulate trailers in
format-patch output. That means it must find the "---"
boundary separating the commit message from the patch.
However, it does so by looking for any line starting with
"---", regardless of whether there is further content.

This is overly lax compared to the parsing done in
mailinfo.c's patchbreak(), and may cause false positives
(e.g., t/perf output tables uses dashes; if you cut and
paste them into your commit message, it fools the parser).

We could try to reuse patchbreak() here, but it actually has
several heuristics that are not of interest to us (e.g.,
matching "diff -" without a three-dash separator or even a
CVS "Index:" line). We're not interested in taking in
whatever random cruft people may send, but rather handling
git-formatted patches.

Note that the existing documentation was written in a loose
way, so technically we are changing the behavior from what
it said. But this should implement the original intent in a
more accurate way.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>trailer: pass process_trailer_opts to trailer_info_get()</title>
<updated>2018-08-23T17:08:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-23T00:46:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=00a21f5cbda35eb5d355b453849b625eeca7eac4'/>
<id>urn:sha1:00a21f5cbda35eb5d355b453849b625eeca7eac4</id>
<content type='text'>
Most of the trailer code has an "opts" struct which is
filled in by the caller. We don't pass it down to
trailer_info_get(), which does the initial parsing, because
there hasn't yet been a need to do so.

Let's start passing it down in preparation for adding new
options. Note that there's a single caller which doesn't
otherwise have such an options struct. Since it's just one
caller (that we'd have to modify anyway), let's not bother
with any special treatment like accepting a NULL options
struct, and just have it allocate one with the defaults.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>trailer: use size_t for iterating trailer list</title>
<updated>2018-08-23T17:08:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-23T00:45:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a3b636e21574e6cff1494e0a84644e06201ddb8d'/>
<id>urn:sha1:a3b636e21574e6cff1494e0a84644e06201ddb8d</id>
<content type='text'>
We store the length of the trailers list in a size_t. So on
a 64-bit system with a 32-bit int, in the unlikely case that
we manage to actually allocate a list with 2^31 entries,
we'd loop forever trying to iterate over it (our "int" would
wrap to negative before exceeding info-&gt;trailer_nr).

This probably doesn't matter in practice. Each entry is at
least a pointer plus a non-empty string, so even without
malloc overhead or the memory to hold the original string
we're parsing from, you'd need to allocate tens of
gigabytes. But it's easy enough to do it right.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>trailer: use size_t for string offsets</title>
<updated>2018-08-23T17:08:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2018-08-23T00:44:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0d2db00e24ee2df4459151c5ba6de9306e30e727'/>
<id>urn:sha1:0d2db00e24ee2df4459151c5ba6de9306e30e727</id>
<content type='text'>
Many of the string-parsing functions inside trailer.c return
integer offsets into the string (e.g., to point to the end
of the trailer block). Several of these use an "int" to
return or store the offsets. On a system where "size_t" is
much larger than "int" (e.g., most 64-bit ones), it's easy
to feed a gigantic commit message that results in a negative
offset. This can result in us reading memory before the
string (if the int is used as an index) or far after (if
it's implicitly cast to a size_t by passing to a strbuf
function).

Let's fix this by using size_t for all string offsets. Note
that several of the functions need ssize_t, since they use
"-1" as a sentinel value. The interactions here can be
pretty subtle. E.g., end_of_title in find_trailer_start()
does not itself need to be signed, but it is compared to the
result of last_line(), which is. That promotes the latter to
unsigned, and the "&gt;=" does not behave as you might expect.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Replace all die("BUG: ...") calls by BUG() ones</title>
<updated>2018-05-06T10:06:13Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2018-05-02T09:38:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=033abf97fcbc247eabf915780181d947cfb66205'/>
<id>urn:sha1:033abf97fcbc247eabf915780181d947cfb66205</id>
<content type='text'>
In d8193743e08 (usage.c: add BUG() function, 2017-05-12), a new macro
was introduced to use for reporting bugs instead of die(). It was then
subsequently used to convert one single caller in 588a538ae55
(setup_git_env: convert die("BUG") to BUG(), 2017-05-12).

The cover letter of the patch series containing this patch
(cf 20170513032414.mfrwabt4hovujde2@sigill.intra.peff.net) is not
terribly clear why only one call site was converted, or what the plan
is for other, similar calls to die() to report bugs.

Let's just convert all remaining ones in one fell swoop.

This trick was performed by this invocation:

	sed -i 's/die("BUG: /BUG("/g' $(git grep -l 'die("BUG' \*.c)

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>trailer: rename 'template' variables</title>
<updated>2018-02-22T18:08:05Z</updated>
<author>
<name>Brandon Williams</name>
<email>bmwill@google.com</email>
</author>
<published>2018-02-14T18:59:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=31c2c7a0ce2b0bd788d1cf7e1f0d14fad8132a7f'/>
<id>urn:sha1:31c2c7a0ce2b0bd788d1cf7e1f0d14fad8132a7f</id>
<content type='text'>
Rename C++ keyword in order to bring the codebase closer to being able
to be compiled with a C++ compiler.

Signed-off-by: Brandon Williams &lt;bmwill@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
