<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/ref-filter.c, branch v2.15.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.15.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.15.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2017-10-11T05:52:22Z</updated>
<entry>
<title>Merge branch 'tb/show-trailers-in-ref-filter'</title>
<updated>2017-10-11T05:52:22Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-11T05:52:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b03cd16613477d3f9ce2e82f3a9fdb5fa99a8b01'/>
<id>urn:sha1:b03cd16613477d3f9ce2e82f3a9fdb5fa99a8b01</id>
<content type='text'>
"git for-each-ref --format=..." learned a new format element,
%(trailers), to show only the commit log trailer part of the log
message.

* tb/show-trailers-in-ref-filter:
  ref-filter.c: parse trailers arguments with %(contents) atom
  ref-filter.c: use trailer_opts to format trailers
  t6300: refactor %(trailers) tests
  doc: use "`&lt;literal&gt;`"-style quoting for literal strings
  doc: 'trailers' is the preferred way to format trailers
  t4205: unfold across multiple lines
</content>
</entry>
<entry>
<title>Merge branch 'tb/ref-filter-empty-modifier'</title>
<updated>2017-10-07T07:27:56Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-10-07T07:27:56Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=43c9e7e365d7a8961767d0bd4a305ca378800a2a'/>
<id>urn:sha1:43c9e7e365d7a8961767d0bd4a305ca378800a2a</id>
<content type='text'>
In the "--format=..." option of the "git for-each-ref" command (and
its friends, i.e. the listing mode of "git branch/tag"), "%(atom:)"
(e.g. "%(refname:)", "%(body:)" used to error out.  Instead, treat
them as if the colon and an empty string that follows it were not
there.

* tb/ref-filter-empty-modifier:
  ref-filter.c: pass empty-string as NULL to atom parsers
</content>
</entry>
<entry>
<title>ref-filter.c: pass empty-string as NULL to atom parsers</title>
<updated>2017-10-05T01:41:57Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2017-10-02T16:10:34Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bea4dbeafda3ddc4404f2e94dce0b66a4105399a'/>
<id>urn:sha1:bea4dbeafda3ddc4404f2e94dce0b66a4105399a</id>
<content type='text'>
Peff points out that different atom parsers handle the empty
"sub-argument" list differently. An example of this is the format
"%(refname:)".

Since callers often use `string_list_split` (which splits the empty
string with any delimiter as a 1-ary string_list containing the empty
string), this makes handling empty sub-argument strings non-ergonomic.

Let's fix this by declaring that atom parser implementations must
not care about distinguishing between the empty string "%(refname:)"
and no sub-arguments "%(refname)".  Current code aborts, either with
"unrecognised arg" (e.g. "refname:") or "does not take args"
(e.g. "body:") as an error message.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Reviewed-by: Jeff King &lt;peff@peff.net&gt;
Reviewed-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter.c: parse trailers arguments with %(contents) atom</title>
<updated>2017-10-02T12:15:30Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2017-10-02T05:25:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7a5edbdb748f58c0ff3f2a459596ad6ddfda0640'/>
<id>urn:sha1:7a5edbdb748f58c0ff3f2a459596ad6ddfda0640</id>
<content type='text'>
The %(contents) atom takes a contents "field" as its argument. Since
"trailers" is one of those fields, extend contents_atom_parser to parse
"trailers"'s arguments when used through "%(contents)", like:

  %(contents:trailers:unfold,only)

A caveat: trailers_atom_parser expects NULL when no arguments are given
(see: `parse_ref_filter_atom`). This is because string_list_split (given
a maxsplit of -1) returns a 1-ary string_list* containing the given
string if the delimiter could not be found using `strchr`.

To simulate this behavior without teaching trailers_atom_parser to
accept strings with length zero, conditionally pass NULL to
trailers_atom_parser if the arguments portion of the argument to
%(contents) is empty.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter.c: use trailer_opts to format trailers</title>
<updated>2017-10-02T12:15:30Z</updated>
<author>
<name>Taylor Blau</name>
<email>me@ttaylorr.com</email>
</author>
<published>2017-10-02T05:25:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=67a20a0010224255bbd5bb9fa4f95595c3e1ba7c'/>
<id>urn:sha1:67a20a0010224255bbd5bb9fa4f95595c3e1ba7c</id>
<content type='text'>
Fill trailer_opts with "unfold" and "only" to match the sub-arguments
given to the "%(trailers)" atom. Then, let's use the filled trailer_opts
instance with 'format_trailers_from_commit' in order to format trailers
in the desired manner.

Signed-off-by: Taylor Blau &lt;me@ttaylorr.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>refs: pass NULL to resolve_refdup() if hash is not needed</title>
<updated>2017-10-01T08:27:14Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-10-01T07:29:03Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=efbd4fdfc9978bf3872ca8cf390da4ffa3480188'/>
<id>urn:sha1:efbd4fdfc9978bf3872ca8cf390da4ffa3480188</id>
<content type='text'>
This allows us to get rid of several write-only variables.

Signed-off-by: Rene Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>ref-filter: consult want_color() before emitting colors</title>
<updated>2017-07-13T19:42:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:09:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11b087adfd469ca597f1d269314f8cad32d0d72f'/>
<id>urn:sha1:11b087adfd469ca597f1d269314f8cad32d0d72f</id>
<content type='text'>
When color placeholders like %(color:red) are used in a
ref-filter format, we unconditionally output the colors,
even if the user has asked us for no colors. This usually
isn't a problem when the user is constructing a --format on
the command line, but it means we may do the wrong thing
when the format is fed from a script or alias. For example:

   $ git config alias.b 'branch --format=%(color:green)%(refname)'
   $ git b --no-color

should probably omit the green color. Likewise, running:

   $ git b &gt;branches

should probably also omit the color, just as we would for
all baked-in coloring (and as we recently started to do for
user-specified colors in --pretty formats).

This commit makes both of those cases work by teaching
the ref-filter code to consult want_color() before
outputting any color. The color flag in ref_format defaults
to "-1", which means we'll consult color.ui, which in turn
defaults to the usual isatty() check on stdout. However,
callers like git-branch which support their own color config
(and command-line options) can override that.

The new tests independently cover all three of the callers
of ref-filter (for-each-ref, tag, and branch). Even though
these seem redundant, it confirms that we've correctly
plumbed through all of the necessary config to make colors
work by default.

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>ref-filter: pass ref_format struct to atom parsers</title>
<updated>2017-07-13T19:42:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:06:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=ab7ded34d6a9a5d4c8bf073cb9627b8054f430cf'/>
<id>urn:sha1:ab7ded34d6a9a5d4c8bf073cb9627b8054f430cf</id>
<content type='text'>
The callback for parsing each formatting atom gets to see
only the atom struct (which it's filling in) and the text to
be parsed. This doesn't leave any room for it to behave
differently based on context known only to the ref_format.

We can solve this by passing in the surrounding ref_format
to each parser. Note that this makes things slightly awkward
for sort strings, which parse atoms without having a
ref_format. We'll solve that by using a dummy ref_format
with default parameters.

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>ref-filter: factor out the parsing of sorting atoms</title>
<updated>2017-07-13T19:42:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:02:58Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=29ef53cd361e8751f9f2f40811af0ce863e449b6'/>
<id>urn:sha1:29ef53cd361e8751f9f2f40811af0ce863e449b6</id>
<content type='text'>
We parse sort strings as single formatting atoms, and just
build on parse_ref_filter_atom(). Let's pull this idea into
its own function, since it's about to get a little more
complex. As a bonus, we can give the function a slightly
more natural interface, since our single atoms are in their
own strings.

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>ref-filter: make parse_ref_filter_atom a private function</title>
<updated>2017-07-13T19:42:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:02:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=aa8a5d144da4e4ec43580831ff4a741538d21db4'/>
<id>urn:sha1:aa8a5d144da4e4ec43580831ff4a741538d21db4</id>
<content type='text'>
The parse_ref_filter_atom() function really shouldn't be
exposed outside of ref-filter.c; its return value is an
integer index into an array that is private in that file.

Since the previous commit removed the sole external caller
(and replaced it with a public function at a more
appropriately level), we can just make this static.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
