<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/ref-filter.c, branch v2.14.3</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://www.git.shady.money/git/atom?h=v2.14.3</id>
<link rel='self' href='https://www.git.shady.money/git/atom?h=v2.14.3'/>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/'/>
<updated>2017-10-05T01:41:57Z</updated>
<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://www.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: 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://www.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://www.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://www.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://www.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>
<entry>
<title>ref-filter: provide a function for parsing sort options</title>
<updated>2017-07-13T19:42:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:02:44Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=18a2565016d45538345a06cd9b912040b5581fc1'/>
<id>urn:sha1:18a2565016d45538345a06cd9b912040b5581fc1</id>
<content type='text'>
The ref-filter module currently provides a callback suitable
for parsing command-line --sort options. But since git-tag
also supports the tag.sort config option, it needs a
function whose implementation is quite similar, but with a
slightly different interface. The end result is that
builtin/tag.c has a copy-paste of parse_opt_ref_sorting().

Instead, let's provide a function to parse an arbitrary
sort string, which we can then trivially wrap to make the
parse_opt variant.

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: move need_color_reset_at_eol into ref_format</title>
<updated>2017-07-13T19:42:50Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:02:30Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=bf285ae6dbfa8e2b847940e6ad987ff3cbe40712'/>
<id>urn:sha1:bf285ae6dbfa8e2b847940e6ad987ff3cbe40712</id>
<content type='text'>
Calling verify_ref_format() doesn't just confirm that the
format is sane; it actually sets some global variables that
will be used later when formatting the refs. These logically
should belong to the ref_format, which would make it
possible to use multiple formats within a single program
invocation.

Let's move one such flag into the ref_format struct. There
are still others that would need to be moved before it would
be safe to use multiple formats, but this commit gives a
blueprint for how that should look.

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: abstract ref format into its own struct</title>
<updated>2017-07-13T19:42:50Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T15:01:18Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=4a68e36d7d106abaf44e3ac960276145b5a25723'/>
<id>urn:sha1:4a68e36d7d106abaf44e3ac960276145b5a25723</id>
<content type='text'>
The ref-filter module provides routines for formatting a ref
for output. The fundamental interface for the format is a
"const char *" containing the format, and any additional
options need to be passed to each invocation of
show_ref_array_item.

Instead, let's make a ref_format struct that holds the
format, along with any associated format options. That will
make some enhancements easier in the future:

  1. new formatting options can be added without disrupting
     existing callers

  2. some state can be carried in the struct rather than as
     global variables

For now this just has the text format itself along with the
quote_style option, but we'll add more fields in 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>ref-filter: simplify automatic color reset</title>
<updated>2017-07-13T19:42:50Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2017-07-13T14:58:56Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=51331aad69a1d89a8b6d1ff82bb5fedbdb6ccc6a'/>
<id>urn:sha1:51331aad69a1d89a8b6d1ff82bb5fedbdb6ccc6a</id>
<content type='text'>
When the user-format doesn't add the closing color reset, we
add one automatically. But we do so by parsing the "reset"
string. We can just use the baked-in string literal, which
is simpler.

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>Merge branch 'kn/ref-filter-branch-list'</title>
<updated>2017-07-12T22:18:23Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-07-12T22:18:23Z</published>
<link rel='alternate' type='text/html' href='https://www.git.shady.money/git/commit/?id=768d0fe0dadbffe722fa4b80b2180a4fcaf1c854'/>
<id>urn:sha1:768d0fe0dadbffe722fa4b80b2180a4fcaf1c854</id>
<content type='text'>
The rewrite of "git branch --list" using for-each-ref's internals
that happened in v2.13 regressed its handling of color.branch.local;
this has been fixed.

* kn/ref-filter-branch-list:
  ref-filter.c: drop return from void function
  branch: set remote color in ref-filter branch immediately
  branch: use BRANCH_COLOR_LOCAL in ref-filter format
  branch: only perform HEAD check for local branches
</content>
</entry>
</feed>
