<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/pretty.c, branch v2.45.4</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.45.4</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.45.4'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2024-04-16T21:50:29Z</updated>
<entry>
<title>Merge branch 'rs/date-mode-pass-by-value'</title>
<updated>2024-04-16T21:50:29Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-16T21:50:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=107313eb11931a66ec4cd3f83bd6c260f296ad19'/>
<id>urn:sha1:107313eb11931a66ec4cd3f83bd6c260f296ad19</id>
<content type='text'>
The codepaths that reach date_mode_from_type() have been updated to
pass "struct date_mode" by value to make them thread safe.

* rs/date-mode-pass-by-value:
  date: make DATE_MODE thread-safe
</content>
</entry>
<entry>
<title>date: make DATE_MODE thread-safe</title>
<updated>2024-04-05T22:21:14Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2024-04-05T17:44:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9720d23e8caf4adee44b3a32803a9bb0480118bd'/>
<id>urn:sha1:9720d23e8caf4adee44b3a32803a9bb0480118bd</id>
<content type='text'>
date_mode_from_type() modifies a static variable and returns a pointer
to it.  This is not thread-safe.  Most callers of date_mode_from_type()
use it via the macro DATE_MODE and pass its result on to functions like
show_date(), which take a const pointer and don't modify the struct.

Avoid the static storage by putting the variable on the stack and
returning the whole struct date_mode.  Change functions that take a
constant pointer to expect the whole struct instead.

Reduce the cost of passing struct date_mode around on 64-bit systems
by reordering its members to close the hole between the 32-bit wide
.type and the 64-bit aligned .strftime_fmt as well as the alignment
hole at the end.  sizeof reports 24 before and 16 with this change
on x64.  Keep .type at the top to still allow initialization without
designator -- though that's only done in a single location, in
builtin/blame.c.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Acked-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'bl/pretty-shorthand-config-fix'</title>
<updated>2024-04-03T17:56:20Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-03T17:56:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d988e80bd3a24387c74810b187a47813f8460699'/>
<id>urn:sha1:d988e80bd3a24387c74810b187a47813f8460699</id>
<content type='text'>
The "--pretty=&lt;shortHand&gt;" option of the commands in the "git log"
family, defined as "[pretty] shortHand = &lt;expansion&gt;" should have
been looked up case insensitively, but was not, which has been
corrected.

* bl/pretty-shorthand-config-fix:
  pretty: find pretty formats case-insensitively
  pretty: update tests to use `test_config`
</content>
</entry>
<entry>
<title>Merge branch 'jk/pretty-subject-cleanup'</title>
<updated>2024-04-01T20:21:34Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2024-04-01T20:21:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a031815a7df317a4387151b1f4af1c85834458b1'/>
<id>urn:sha1:a031815a7df317a4387151b1f4af1c85834458b1</id>
<content type='text'>
Code clean-up in the "git log" machinery that implements custom log
message formatting.

* jk/pretty-subject-cleanup:
  format-patch: fix leak of empty header string
  format-patch: simplify after-subject MIME header handling
  format-patch: return an allocated string from log_write_email_headers()
  log: do not set up extra_headers for non-email formats
  pretty: drop print_email_subject flag
  pretty: split oneline and email subject printing
  shortlog: stop setting pp.print_email_subject
</content>
</entry>
<entry>
<title>pretty: find pretty formats case-insensitively</title>
<updated>2024-03-25T19:19:48Z</updated>
<author>
<name>Brian Lyles</name>
<email>brianmlyles@gmail.com</email>
</author>
<published>2024-03-25T07:25:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f999d5188b4060aa0f784a6f4cf1574ea352a1e7'/>
<id>urn:sha1:f999d5188b4060aa0f784a6f4cf1574ea352a1e7</id>
<content type='text'>
User-defined pretty formats are stored in config, which is meant to use
case-insensitive matching for names as noted in config.txt's 'Syntax'
section:

    All the other lines [...] are recognized as setting variables, in
    the form 'name = value' [...]. The variable names are
    case-insensitive, [...].

When a user specifies one of their format aliases with an uppercase in
it, however, it is not found.

    $ git config pretty.testAlias %h
    $ git config --list | grep pretty
    pretty.testalias=%h
    $ git log --format=testAlias -1
    fatal: invalid --pretty format: testAlias
    $ git log --format=testalias -1
    3c2a3fdc38

This is true whether the name in the config file uses any uppercase
characters or not.

Use case-insensitive comparisons when identifying format aliases.

Co-authored-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Brian Lyles &lt;brianmlyles@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: drop print_email_subject flag</title>
<updated>2024-03-20T00:54:15Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-03-20T00:30:44Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d5a90d6319aeb6cb3f0b795156c4c2259373424f'/>
<id>urn:sha1:d5a90d6319aeb6cb3f0b795156c4c2259373424f</id>
<content type='text'>
With one exception, the print_email_subject flag is set if and only if
the commit format is email based:

  - in make_cover_letter() we set it along with CMIT_FMT_EMAIL
    explicitly

  - in show_log(), we set it if cmit_fmt_is_mail() is true. That covers
    format-patch as well as "git log --format=email" (or mboxrd).

The one exception is "rev-list --format=email", which somewhat
nonsensically prints the author and date as email headers, but no
subject, like:

  $ git rev-list --format=email HEAD
  commit 64fc4c2cdd4db2645eaabb47aa4bac820b03cdba
  From: Jeff King &lt;peff@peff.net&gt;
  Date: Tue, 19 Mar 2024 19:39:26 -0400

  this is the subject

  this is the body

It's doubtful that this is a useful format at all (the "commit" lines
replace the "From" lines that would make it work as an actual mbox).
But I think that printing the subject as a header (like this patch does)
is the least surprising thing to do.

So let's drop this field, making the code a little simpler and easier to
reason about. Note that we do need to set the "rev" field of the
pretty_print_context in rev-list, since that is used to check for
subject_prefix, etc. It's not possible to set those fields via rev-list,
so we'll always just print "Subject: ". But unless we pass in our
rev_info, fmt_output_email_subject() would segfault trying to figure it
out.

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>pretty: split oneline and email subject printing</title>
<updated>2024-03-20T00:54:15Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2024-03-20T00:28:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=69aff6200c51cc8a91111b80fbfb84792ce0908c'/>
<id>urn:sha1:69aff6200c51cc8a91111b80fbfb84792ce0908c</id>
<content type='text'>
The pp_title_line() function is used for two formats: the oneline format
and the subject line of the email format. But most of the logic in the
function does not make any sense for oneline; it is about special
formatting of email headers.

Lumping the two formats together made sense long ago in 4234a76167
(Extend --pretty=oneline to cover the first paragraph, 2007-06-11), when
there was a lot of manual logic to paste lines together. But later,
88c44735ab (pretty: factor out format_subject(), 2008-12-27) pulled that
logic into its own function.

We can implement the oneline format by just calling that one function.
This makes the intention of the code much more clear, as we know we only
need to worry about those extra email options when dealing with actual
email.

While the intent here is cleanup, it is possible to trigger these cases
in practice by running format-patch with an explicit --oneline option.
But if you did, the results are basically nonsense. For example, with
the preserve_subject flag:

  $ printf "%s\n" one two three | git commit --allow-empty -F -
  $ git format-patch -1 --stdout -k | grep ^Subject
  Subject: =?UTF-8?q?one=0Atwo=0Athree?=
  $ git format-patch -1 --stdout -k --oneline --no-signature
  2af7fbe one
  two
  three

Or with extra headers:

  $ git format-patch -1 --stdout --cc=me --oneline --no-signature
  2af7fbe one two three
  Cc: me

So I'd actually consider this to be an improvement, though you are
probably crazy to use other formats with format-patch in the first place
(arguably it should forbid non-email formats entirely, but that's a
bigger change).

As a bonus, it eliminates some pointless extra allocations for the
oneline output. The email code, since it has to deal with wrapping,
formats into an extra auxiliary buffer. The speedup is tiny, though like
"rev-list --no-abbrev --format=oneline" seems to improve by a consistent
1-2% for me.

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: reorder format_trailers_from_commit() parameters</title>
<updated>2024-03-01T18:35:42Z</updated>
<author>
<name>Linus Arver</name>
<email>linusa@google.com</email>
</author>
<published>2024-03-01T00:14:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0383dc5629dc4416b6564e5b458d174d770ef191'/>
<id>urn:sha1:0383dc5629dc4416b6564e5b458d174d770ef191</id>
<content type='text'>
Currently there are two functions for formatting trailers in
&lt;trailer.h&gt;:

    void format_trailers(const struct process_trailer_options *,
                         struct list_head *trailers, FILE *outfile);

    void format_trailers_from_commit(struct strbuf *out, const char *msg,
                                     const struct process_trailer_options *opts);

and although they are similar enough (even taking the same
process_trailer_options struct pointer) they are used quite differently.
One might intuitively think that format_trailers_from_commit() builds on
top of format_trailers(), but this is not the case. Instead
format_trailers_from_commit() calls format_trailer_info() and
format_trailers() is never called in that codepath.

This is a preparatory refactor to help us deprecate format_trailers() in
favor of format_trailer_info() (at which point we can rename the latter
to the former). When the deprecation is complete, both
format_trailers_from_commit(), and the interpret-trailers builtin will
be able to call into the same helper function (instead of
format_trailers() and format_trailer_info(), respectively). Unifying the
formatters is desirable because it simplifies the API.

Reorder parameters for format_trailers_from_commit() to prefer

    const struct process_trailer_options *opts

as the first parameter, because these options are intimately tied to
formatting trailers. And take

    struct strbuf *out

last, because it's an "out parameter" (something that the caller wants
to use as the output of this function).

Similarly, reorder parameters for format_trailer_info(), because later
on we will unify the two together.

Signed-off-by: Linus Arver &lt;linusa@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: fix ref filtering for %(decorate) formats</title>
<updated>2023-10-09T18:25:13Z</updated>
<author>
<name>Andy Koppe</name>
<email>andy.koppe@gmail.com</email>
</author>
<published>2023-10-08T20:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2b09d16abac5c0cf389098a58f113f2053357dee'/>
<id>urn:sha1:2b09d16abac5c0cf389098a58f113f2053357dee</id>
<content type='text'>
Mark pretty formats containing "%(decorate" as requiring decoration in
userformat_find_requirements(), same as "%d" and "%D".

Without this, cmd_log_init_finish() didn't invoke load_ref_decorations()
with the decoration_filter it puts together, and hence filtering options
such as --decorate-refs were quietly ignored.

Amend one of the %(decorate) checks in t4205-log-pretty-formats.sh to
test this.

Signed-off-by: Andy Koppe &lt;andy.koppe@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>pretty: add pointer and tag options to %(decorate)</title>
<updated>2023-08-21T18:40:10Z</updated>
<author>
<name>Andy Koppe</name>
<email>andy.koppe@gmail.com</email>
</author>
<published>2023-08-20T18:50:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f1f8a258567268974b9bbd012c33ad219a31aa0e'/>
<id>urn:sha1:f1f8a258567268974b9bbd012c33ad219a31aa0e</id>
<content type='text'>
Add pointer and tag options to %(decorate) format, to allow to override
the " -&gt; " string used to show where HEAD points and the "tag: " string
used to mark tags.

Document in pretty-formats.txt and test in t4205-log-pretty-formats.sh.

Signed-off-by: Andy Koppe &lt;andy.koppe@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
