<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/log-tree.c, branch v2.3.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.3.0</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.3.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2014-10-20T19:23:48Z</updated>
<entry>
<title>Merge branch 'jn/parse-config-slot'</title>
<updated>2014-10-20T19:23:48Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-10-20T19:23:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b94657683996402228abb1694a5db4792c424f9e'/>
<id>urn:sha1:b94657683996402228abb1694a5db4792c424f9e</id>
<content type='text'>
Code cleanup.

* jn/parse-config-slot:
  color_parse: do not mention variable name in error message
  pass config slots as pointers instead of offsets
</content>
</entry>
<entry>
<title>color_parse: do not mention variable name in error message</title>
<updated>2014-10-14T18:01:21Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-10-07T19:33:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=f6c5a2968c103621adf6928a29e4895361eaa23b'/>
<id>urn:sha1:f6c5a2968c103621adf6928a29e4895361eaa23b</id>
<content type='text'>
Originally the color-parsing function was used only for
config variables. It made sense to pass the variable name so
that the die() message could be something like:

  $ git -c color.branch.plain=bogus branch
  fatal: bad color value 'bogus' for variable 'color.branch.plain'

These days we call it in other contexts, and the resulting
error messages are a little confusing:

  $ git log --pretty='%C(bogus)'
  fatal: bad color value 'bogus' for variable '--pretty format'

  $ git config --get-color foo.bar bogus
  fatal: bad color value 'bogus' for variable 'command line'

This patch teaches color_parse to complain only about the
value, and then return an error code. Config callers can
then propagate that up to the config parser, which mentions
the variable name. Other callers can provide a custom
message. After this patch these three cases now look like:

  $ git -c color.branch.plain=bogus branch
  error: invalid color value: bogus
  fatal: unable to parse 'color.branch.plain' from command-line config

  $ git log --pretty='%C(bogus)'
  error: invalid color value: bogus
  fatal: unable to parse --pretty format

  $ git config --get-color foo.bar bogus
  error: invalid color value: bogus
  fatal: unable to parse default color value

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>pass config slots as pointers instead of offsets</title>
<updated>2014-10-14T18:01:05Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2014-10-07T19:16:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8852117a603c5ed5131233a80453db37c0958871'/>
<id>urn:sha1:8852117a603c5ed5131233a80453db37c0958871</id>
<content type='text'>
Many config-parsing helpers, like parse_branch_color_slot,
take the name of a config variable and an offset to the
"slot" name (e.g., "color.branch.plain" is passed along with
"13" to effectively pass "plain"). This is leftover from the
time that these functions would die() on error, and would
want the full variable name for error reporting.

These days they do not use the full variable name at all.
Passing a single pointer to the slot name is more natural,
and lets us more easily adjust the callers to use skip_prefix
to avoid manually writing offset numbers.

This is effectively a continuation of 9e1a5eb, which did the
same for parse_diff_color_slot. This patch covers all of the
remaining similar constructs.

Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
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 'hj/pretty-naked-decoration'</title>
<updated>2014-09-29T19:36:09Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-09-29T19:36:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b8e533f12acec63242c5405286fbbcfa66eecfdd'/>
<id>urn:sha1:b8e533f12acec63242c5405286fbbcfa66eecfdd</id>
<content type='text'>
The pretty-format specifier "%d", which expanded to " (tagname)"
for a tagged commit, gained a cousin "%D" that just gives the
"tagname" without frills.

* hj/pretty-naked-decoration:
  pretty: add %D format specifier
</content>
</entry>
<entry>
<title>pretty: add %D format specifier</title>
<updated>2014-09-18T22:15:21Z</updated>
<author>
<name>Harry Jeffery</name>
<email>harry@exec64.co.uk</email>
</author>
<published>2014-09-18T20:53:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9271095cc5571e306d709ebf8eb7f0a388254d9d'/>
<id>urn:sha1:9271095cc5571e306d709ebf8eb7f0a388254d9d</id>
<content type='text'>
Add a new format specifier, '%D' that is identical in behaviour to '%d',
except that it does not include the ' (' prefix or ')' suffix provided
by '%d'.

Signed-off-by: Harry Jeffery &lt;harry@exec64.co.uk&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/name-decoration-alloc'</title>
<updated>2014-09-11T17:33:36Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2014-09-11T17:33:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1ebe6a825a1ff12e12905e28265aa30e269700d6'/>
<id>urn:sha1:1ebe6a825a1ff12e12905e28265aa30e269700d6</id>
<content type='text'>
The API to allocate the structure to keep track of commit
decoration was cumbersome to use, inviting lazy code to
overallocate memory.

* jk/name-decoration-alloc:
  log-tree: use FLEX_ARRAY in name_decoration
  log-tree: make name_decoration hash static
  log-tree: make add_name_decoration a public function
</content>
</entry>
<entry>
<title>log-tree: use FLEX_ARRAY in name_decoration</title>
<updated>2014-08-27T14:44:27Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-08-26T10:24:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e3dfb216991974b60fdb1933eb3331e03383e61'/>
<id>urn:sha1:2e3dfb216991974b60fdb1933eb3331e03383e61</id>
<content type='text'>
We are already using the flex-array technique; let's
annotate it with our usual FLEX_ARRAY macro. Besides being
more readable, this is slightly more efficient on compilers
that understand flex-arrays.

Note that we need to bump the allocation in add_name_decoration,
which did not explicitly add one byte for the NUL terminator
of the string we are putting into the flex-array (it did not
need to before, because the struct itself was over-allocated
by one byte).

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>log-tree: make name_decoration hash static</title>
<updated>2014-08-26T17:34:26Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-08-26T10:23:54Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2608c24940c80bf379937e4cefee75e2db79e008'/>
<id>urn:sha1:2608c24940c80bf379937e4cefee75e2db79e008</id>
<content type='text'>
In the previous commit, we made add_name_decoration global
so that adders would not have to access the hash directly.
We now make the hash itself static so that callers _have_ to
add through our function, making sure that all additions go
through a single point.  To do this, we have to add one more
accessor function: a way to lookup entries in the hash.

Since the only caller doesn't actually look at the returned
value, but rather only asks whether there is a decoration or
not, we could provide only a boolean "has_name_decoration".
That would allow us to make "struct name_decoration" local
to log-tree, as well.

However, it's unlikely to cause any maintainability harm
making the actual data public, and this interface is more
flexible if we need to look at decorations from other parts
of the code in the future.

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>log-tree: make add_name_decoration a public function</title>
<updated>2014-08-26T17:33:01Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-08-26T10:23:36Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=662174d299a2221016a8756d35d485b576ebcec2'/>
<id>urn:sha1:662174d299a2221016a8756d35d485b576ebcec2</id>
<content type='text'>
The log-tree code keeps a "struct decoration" hash to show
text decorations for each commit during log traversals. It
makes this available to other files by providing global
access to the hash. This can result in other code adding
entries that do not conform to what log-tree expects.

For example, the bisect code adds its own "dist"
decorations to be shown. Originally the bisect code was
correct, but when the name_decoration code grew a new field
in eb3005e (commit.h: add 'type' to struct name_decoration,
2010-06-19), the bisect code was not updated. As a result,
the log-tree code can access uninitialized memory and even
segfault.

We can fix this by making name_decoration's adding function
public. If all callers use it, then any changes to struct
initialization only need to happen in one place (and because
the members come in as parameters, the compiler can notice a
caller who does not supply enough information).

As a bonus, this also means that the decoration hashes
created by the bisect code will use less memory (previously
we over-allocated space for the distance integer, but now we
format it into a temporary buffer and copy it to the final
flex-array).

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: make empty userformats truly empty</title>
<updated>2014-07-30T19:30:08Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2014-07-29T17:56:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b9c7d6e4330e3dcdb3b3e5f013e5667e47555c95'/>
<id>urn:sha1:b9c7d6e4330e3dcdb3b3e5f013e5667e47555c95</id>
<content type='text'>
If the user provides an empty format with "--format=", we
end up putting in extra whitespace that the user cannot
prevent. This comes from two places:

  1. If the format is missing a terminating newline, we add
     one automatically. This makes sense for --format=%h, but
     not for a truly empty format.

  2. We add an extra newline between the pretty-printed
     format and a diff or diffstat. If the format is empty,
     there's no point in doing so if there's nothing to
     separate.

With this patch, one can get a diff with no other cruft out
of "diff-tree --format= $commit".

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