<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/notes.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-09-19T01:47:52Z</updated>
<entry>
<title>Merge branch 'mh/notes-cleanup'</title>
<updated>2017-09-19T01:47:52Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2017-09-19T01:47:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=30675f7021f92b0e830fdb3c96370826d8f6723f'/>
<id>urn:sha1:30675f7021f92b0e830fdb3c96370826d8f6723f</id>
<content type='text'>
Code clean-up.

* mh/notes-cleanup:
  load_subtree(): check that `prefix_len` is in the expected range
  load_subtree(): declare some variables to be `size_t`
  hex_to_bytes(): simpler replacement for `get_oid_hex_segment()`
  get_oid_hex_segment(): don't pad the rest of `oid`
  load_subtree(): combine some common code
  get_oid_hex_segment(): return 0 on success
  load_subtree(): only consider blobs to be potential notes
  load_subtree(): check earlier whether an internal node is a tree entry
  load_subtree(): separate logic for internal vs. terminal entries
  load_subtree(): fix incorrect comment
  load_subtree(): reduce the scope of some local variables
  load_subtree(): remove unnecessary conditional
  notes: make GET_NIBBLE macro more robust
</content>
</entry>
<entry>
<title>load_subtree(): check that `prefix_len` is in the expected range</title>
<updated>2017-09-08T18:16:13Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-09-08T16:10:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=396428152413f431cac18f68a7190827b4acb3b6'/>
<id>urn:sha1:396428152413f431cac18f68a7190827b4acb3b6</id>
<content type='text'>
This value, which is stashed in the last byte of an object_id hash,
gets handed around a lot. So add a sanity check before using it in
`load_subtree()`.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>load_subtree(): declare some variables to be `size_t`</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=06cfa75675ac605577c9a42154a9042bfd451937'/>
<id>urn:sha1:06cfa75675ac605577c9a42154a9042bfd451937</id>
<content type='text'>
* `prefix_len`
* `path_len`
* `i`

It's good hygiene.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hex_to_bytes(): simpler replacement for `get_oid_hex_segment()`</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cfdc88f1a34ccb8e59899501b0ede875afac0d83'/>
<id>urn:sha1:cfdc88f1a34ccb8e59899501b0ede875afac0d83</id>
<content type='text'>
Now that `get_oid_hex_segment()` does less, it makes sense to rename
it and simplify its semantics:

* Instead of a `hex_len` parameter, which was the number of hex
  characters (and had to be even), use a `len` parameter, which is the
  number of resulting bytes. This removes then need for the check that
  `hex_len` is even and to divide it by two to determine the number of
  bytes. For good hygiene, declare the `len` parameter to be `size_t`
  instead of `unsigned int`.

* Change the order of the arguments to the more traditional (dst,
  src, len).

* Rename the function to `hex_to_bytes()`.

* Remove a loop variable: just count `len` down instead.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>get_oid_hex_segment(): don't pad the rest of `oid`</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d49852d6f89bfde3cb20b6ca5866f67f6c04a894'/>
<id>urn:sha1:d49852d6f89bfde3cb20b6ca5866f67f6c04a894</id>
<content type='text'>
Remove the feature of `get_oid_hex_segment()` that it pads the rest of
the `oid` argument with zeros. Instead, do this at the caller who
needs it.

This makes the functionality of this function more coherent and
removes the need for its `oid_len` argument.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>load_subtree(): combine some common code</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4ebef533d75a197f660b38d615489ad8a233bba1'/>
<id>urn:sha1:4ebef533d75a197f660b38d615489ad8a233bba1</id>
<content type='text'>
Write the length into `object_oid` (before copying) rather than
`l-&gt;key_oid` (after copying). Then combine some code from the two `if`
blocks.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>get_oid_hex_segment(): return 0 on success</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=67c9b422513ac601c68c191a026af968a2838ae1'/>
<id>urn:sha1:67c9b422513ac601c68c191a026af968a2838ae1</id>
<content type='text'>
Nobody cares about the return value of get_oid_hex_segment() except to
check whether it failed. So just return 0 on success.

And while we're updating its docstring, update it for some argument
renaming that happened a while ago.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>load_subtree(): only consider blobs to be potential notes</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=404321879585b392118c9f4c3c4c9e4ccd6ba09f'/>
<id>urn:sha1:404321879585b392118c9f4c3c4c9e4ccd6ba09f</id>
<content type='text'>
The old code converted any entry whose path constituted a full SHA-1
as a leaf node, without regard for the type of the entry. But only
blobs can be notes. So treat entries whose paths *look like* notes
paths but that are not blobs as non-notes.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>load_subtree(): check earlier whether an internal node is a tree entry</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=4d589b87e857015b4f78e47353f87d4aa717b1a0'/>
<id>urn:sha1:4d589b87e857015b4f78e47353f87d4aa717b1a0</id>
<content type='text'>
If an entry is not a tree entry, then it cannot possibly be an
internal node. But the old code checked this condition only after
allocating a leaf_node object and therefore leaked that memory.
Instead, check before even entering this branch of the code.

Signed-off-by: Michael Haggerty &lt;mhagger@alum.mit.edu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>load_subtree(): separate logic for internal vs. terminal entries</title>
<updated>2017-08-26T16:21:01Z</updated>
<author>
<name>Michael Haggerty</name>
<email>mhagger@alum.mit.edu</email>
</author>
<published>2017-08-26T08:28:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=98c9897d9e40f49cfb416801851656bac494ae40'/>
<id>urn:sha1:98c9897d9e40f49cfb416801851656bac494ae40</id>
<content type='text'>
There are only two legitimate notes path components:

* A hexadecimal string that fills the rest of the SHA-1

* A two-digit hexadecimal string that constitutes another internal
  node.

So handle those two cases at the top level, and reject others as
non-notes without trying to parse them. The logic separation also
simplifies upcoming changes.

This prevents us from leaking memory for a leaf_node in the case of
wrong-sized paths. There are still memory leaks in this code; they will
be fixed in upcoming commits.

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