<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/pretty.c, branch v2.32.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.32.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.32.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-04-27T07:09:32Z</updated>
<entry>
<title>pretty: provide human date format</title>
<updated>2021-04-27T07:09:32Z</updated>
<author>
<name>ZheNing Hu</name>
<email>adlternative@gmail.com</email>
</author>
<published>2021-04-25T10:41:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b722d4560e9d566cb8c6cdccf08d649df146eb6b'/>
<id>urn:sha1:b722d4560e9d566cb8c6cdccf08d649df146eb6b</id>
<content type='text'>
Add the placeholders %ah and %ch to format author date and committer
date, like --date=human does, which provides more humanity date output.

Signed-off-by: ZheNing Hu &lt;adlternative@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/pretty-describe'</title>
<updated>2021-03-22T21:00:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-03-22T21:00:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=25f9326561292b45311c60879d9bc08618727973'/>
<id>urn:sha1:25f9326561292b45311c60879d9bc08618727973</id>
<content type='text'>
"git log --format='...'" learned "%(describe)" placeholder.

* rs/pretty-describe:
  archive: expand only a single %(describe) per archive
  pretty: document multiple %(describe) being inconsistent
  t4205: assert %(describe) test coverage
  pretty: add merge and exclude options to %(describe)
  pretty: add %(describe)
</content>
</entry>
<entry>
<title>use CALLOC_ARRAY</title>
<updated>2021-03-14T00:00:09Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-03-13T16:17:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ca56dadb4b65ccaeab809d80db80a312dc00941a'/>
<id>urn:sha1:ca56dadb4b65ccaeab809d80db80a312dc00941a</id>
<content type='text'>
Add and apply a semantic patch for converting code that open-codes
CALLOC_ARRAY to use it instead.  It shortens the code and infers the
element size automatically.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>archive: expand only a single %(describe) per archive</title>
<updated>2021-03-11T21:22:44Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-02-28T11:22:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=96099726ddb00b45135964220ce56468ba9fe184'/>
<id>urn:sha1:96099726ddb00b45135964220ce56468ba9fe184</id>
<content type='text'>
Every %(describe) placeholder in $Format:...$ strings in files with the
attribute export-subst is expanded by calling git describe.  This can
potentially result in a lot of such calls per archive.  That's OK for
local repositories under control of the user of git archive, but could
be a problem for hosted repositories.

Expand only a single %(describe) placeholder per archive for now to
avoid denial-of-service attacks.  We can make this limit configurable
later if needed, but let's start out simple.

Reported-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'hv/trailer-formatting'</title>
<updated>2021-03-01T22:02:58Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-03-01T22:02:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=28714238c8d482345ca17e8dd98d8cc328de24a8'/>
<id>urn:sha1:28714238c8d482345ca17e8dd98d8cc328de24a8</id>
<content type='text'>
The logic to handle "trailer" related placeholders in the
"--format=" mechanisms in the "log" family and "for-each-ref"
family is getting unified.

* hv/trailer-formatting:
  ref-filter: use pretty.c logic for trailers
  pretty.c: capture invalid trailer argument
  pretty.c: refactor trailer logic to `format_set_trailers_options()`
  t6300: use function to test trailer options
</content>
</entry>
<entry>
<title>pretty: add merge and exclude options to %(describe)</title>
<updated>2021-02-17T17:54:33Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-02-14T10:10:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b081547ec1de57162f2c1c7748aa09c861413d34'/>
<id>urn:sha1:b081547ec1de57162f2c1c7748aa09c861413d34</id>
<content type='text'>
Allow restricting the tags used by the placeholder %(describe) with the
options match and exclude.  E.g. the following command describes the
current commit using official version tags, without those for release
candidates:

   $ git log -1 --format='%(describe:match=v[0-9]*,exclude=*rc*)'

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: add %(describe)</title>
<updated>2021-02-17T17:54:31Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2021-02-14T10:04:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=15ae82d5d6ccdcad00aeb456ff512d3031f03039'/>
<id>urn:sha1:15ae82d5d6ccdcad00aeb456ff512d3031f03039</id>
<content type='text'>
Add a format placeholder for describe output.  Implement it by actually
calling git describe, which is simple and guarantees correctness.  It's
intended to be used with $Format:...$ in files with the attribute
export-subst and git archive.  It can also be used with git log etc.,
even though that's going to be slow due to the fork for each commit.

Suggested-by: Eli Schwartz &lt;eschwartz@archlinux.org&gt;
Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty.c: capture invalid trailer argument</title>
<updated>2021-02-16T00:48:38Z</updated>
<author>
<name>Hariom Verma</name>
<email>hariom18599@gmail.com</email>
</author>
<published>2021-02-13T01:52:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=636a0aeedfee5f3cce2ebf1fcc174a49ab9bb0c3'/>
<id>urn:sha1:636a0aeedfee5f3cce2ebf1fcc174a49ab9bb0c3</id>
<content type='text'>
As we would like to use this trailers logic in the ref-filter, it's
nice to get an invalid trailer argument. This will allow us to print
precise error message while using `format_set_trailers_options()` in
ref-filter.

For capturing the invalid argument, we changed the working of
`format_set_trailers_options()` a little bit.
Original logic does "break" and fell through in mainly 2 cases -
    1. unknown/invalid argument
    2. end of the arg string

But now instead of "break", we capture invalid argument and return
non-zero. And non-zero is handled by the caller.
(We prepared the caller to handle non-zero in the previous commit).

Capturing invalid arguments this way will also affects the working
of current logic. As at the end of the arg string it will return non-zero.
So in order to make things correct, introduced an additional conditional
statement i.e if encounter ")", do 'break'.

Mentored-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Mentored-by: Heba Waly &lt;heba.waly@gmail.com&gt;
Signed-off-by: Hariom Verma &lt;hariom18599@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty.c: refactor trailer logic to `format_set_trailers_options()`</title>
<updated>2021-02-16T00:48:38Z</updated>
<author>
<name>Hariom Verma</name>
<email>hariom18599@gmail.com</email>
</author>
<published>2021-02-13T01:52:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=90563aedcab92b75d4b5f6d7aa43d6a98aaccde6'/>
<id>urn:sha1:90563aedcab92b75d4b5f6d7aa43d6a98aaccde6</id>
<content type='text'>
Refactored trailers formatting logic inside pretty.c to a new function
`format_set_trailers_options()`. This new function returns the non-zero
in case of unusual. The caller handles the non-zero by "goto trailers_out".

This change will allow us to reuse the same logic in other places.

Mentored-by: Christian Couder &lt;chriscool@tuxfamily.org&gt;
Mentored-by: Heba Waly &lt;heba.waly@gmail.com&gt;
Signed-off-by: Hariom Verma &lt;hariom18599@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: lazy-load commit data when expanding user-format</title>
<updated>2021-01-28T22:07:35Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2021-01-28T19:57:39Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=018b9deba5c4971f321f2158e3a6308f479bfee3'/>
<id>urn:sha1:018b9deba5c4971f321f2158e3a6308f479bfee3</id>
<content type='text'>
When we expand a user-format, we try to avoid work that isn't necessary
for the output. For instance, we don't bother parsing the commit header
until we know we need the author, subject, etc.

But we do always load the commit object's contents from disk, even if
the format doesn't require it (e.g., just "%H"). Traditionally this
didn't matter much, because we'd have loaded it as part of the traversal
anyway, and we'd typically have those bytes attached to the commit
struct (or these days, cached in a commit-slab).

But when we have a commit-graph, we might easily get to the point of
pretty-printing a commit without ever having looked at the actual object
contents. We should push off that load (and reencoding) until we're
certain that it's needed.

I think the results of p4205 show the advantage pretty clearly (we serve
parent and tree oids out of the commit struct itself, so they benefit as
well):

  # using git.git as the test repo
  Test                          HEAD^             HEAD
  ----------------------------------------------------------------------
  4205.1: log with %H           0.40(0.39+0.01)   0.03(0.02+0.01) -92.5%
  4205.2: log with %h           0.45(0.44+0.01)   0.09(0.09+0.00) -80.0%
  4205.3: log with %T           0.40(0.39+0.00)   0.04(0.04+0.00) -90.0%
  4205.4: log with %t           0.46(0.46+0.00)   0.09(0.08+0.01) -80.4%
  4205.5: log with %P           0.39(0.39+0.00)   0.03(0.03+0.00) -92.3%
  4205.6: log with %p           0.46(0.46+0.00)   0.10(0.09+0.00) -78.3%
  4205.7: log with %h-%h-%h     0.52(0.51+0.01)   0.15(0.14+0.00) -71.2%
  4205.8: log with %an-%ae-%s   0.42(0.41+0.00)   0.42(0.41+0.01) +0.0%

  # using linux.git as the test repo
  Test                          HEAD^             HEAD
  ----------------------------------------------------------------------
  4205.1: log with %H           7.12(6.97+0.14)   0.76(0.65+0.11) -89.3%
  4205.2: log with %h           7.35(7.19+0.16)   1.30(1.19+0.11) -82.3%
  4205.3: log with %T           7.58(7.42+0.15)   1.02(0.94+0.08) -86.5%
  4205.4: log with %t           8.05(7.89+0.15)   1.55(1.41+0.13) -80.7%
  4205.5: log with %P           7.12(7.01+0.10)   0.76(0.69+0.07) -89.3%
  4205.6: log with %p           7.38(7.27+0.10)   1.32(1.20+0.12) -82.1%
  4205.7: log with %h-%h-%h     7.81(7.67+0.13)   1.79(1.67+0.12) -77.1%
  4205.8: log with %an-%ae-%s   7.90(7.74+0.15)   7.81(7.66+0.15) -1.1%

I added the final test to show where we don't improve (the 1% there is
just lucky noise), but also as a regression test to make sure we're not
doing anything stupid like loading the commit multiple times when there
are several placeholders that need it.

Reported-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
