<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/hex.c, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2018-11-14T07:54:52Z</updated>
<entry>
<title>hex: introduce functions to print arbitrary hashes</title>
<updated>2018-11-14T07:54:52Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-11-14T04:09:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=47edb649973cf5cd5f7066b5c936b330f78d687b'/>
<id>urn:sha1:47edb649973cf5cd5f7066b5c936b330f78d687b</id>
<content type='text'>
Currently, we have functions that turn an arbitrary SHA-1 value or an
object ID into hex format, either using a static buffer or with a
user-provided buffer.  Add variants of these functions that can handle
an arbitrary hash algorithm, specified by constant.  Update the
documentation as well.

While we're at it, remove the "extern" declaration from this family of
functions, since it's not needed and our style now recommends against
it.

We use the variant taking the algorithm structure pointer as the
internal variant, since taking an algorithm pointer is the easiest way
to handle all of the variants in use.

Note that we maintain these functions because there are hashes which
must change based on the hash algorithm in use but are not object IDs
(such as pack checksums).

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hex: switch to using the_hash_algo</title>
<updated>2018-07-16T21:27:39Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2018-07-16T01:27:55Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d9cd734990a5fedbf7fc34debe6c10d5d10e954a'/>
<id>urn:sha1:d9cd734990a5fedbf7fc34debe6c10d5d10e954a</id>
<content type='text'>
Instead of using the GIT_SHA1_* constants, switch to using the_hash_algo
to convert object IDs to and from hex format.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>notes: move hex_to_bytes() to hex.c and export it</title>
<updated>2017-11-01T01:35:35Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2017-10-31T13:46:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0ec218656a02ea48e173262f7b80513feeb7f263'/>
<id>urn:sha1:0ec218656a02ea48e173262f7b80513feeb7f263</id>
<content type='text'>
Make the function for converting pairs of hexadecimal digits to binary
available to other call sites.

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>Convert GIT_SHA1_HEXSZ used for allocation to GIT_MAX_HEXSZ</title>
<updated>2017-03-27T05:08:21Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-03-26T16:01:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=dc01505f7f272a44b974e622f75bd592debe9dcb'/>
<id>urn:sha1:dc01505f7f272a44b974e622f75bd592debe9dcb</id>
<content type='text'>
Since we will likely be introducing a new hash function at some point,
and that hash function might be longer than 40 hex characters, use the
constant GIT_MAX_HEXSZ, which is designed to be suitable for
allocations, instead of GIT_SHA1_HEXSZ.  This will ease the transition
down the line by distinguishing between places where we need to allocate
memory suitable for the largest hash from those where we need to handle
the current hash.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hex: introduce parse_oid_hex</title>
<updated>2017-02-20T09:11:26Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2017-02-20T00:10:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=605f430efb23ce14ca11750368149acd38b8f1e4'/>
<id>urn:sha1:605f430efb23ce14ca11750368149acd38b8f1e4</id>
<content type='text'>
Introduce a function, parse_oid_hex, which parses a hexadecimal object
ID and if successful, sets a pointer to just beyond the last character.
This allows for simpler, more robust parsing without needing to
hard-code integer values throughout the codebase.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>hex: make wraparound of the index into ring-buffer explicit</title>
<updated>2016-10-26T17:54:11Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-10-23T17:57:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bb84735c80dbae6408b79b56f574ae672d2232d4'/>
<id>urn:sha1:bb84735c80dbae6408b79b56f574ae672d2232d4</id>
<content type='text'>
Overflow is defined for unsigned integers, but not for signed ones.

We could make the ring-buffer index in sha1_to_hex() and
get_pathname() unsigned to be on the safe side to resolve this, but
let's make it explicit that we are wrapping around at whatever the
number of elements the ring-buffer has.  The compiler is smart enough
to turn modulus into bitmask for these codepaths that use
ring-buffers of a size that is a power of 2.

Signed-off-by: René Scharfe &lt;l.s.r@web.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'rs/hex2chr' into maint</title>
<updated>2016-09-19T20:51:43Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2016-09-19T20:51:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c3befaeab9ebd0def9f03d434a52cf40614c65f9'/>
<id>urn:sha1:c3befaeab9ebd0def9f03d434a52cf40614c65f9</id>
<content type='text'>
Code cleanup.

* rs/hex2chr:
  introduce hex2chr() for converting two hexadecimal digits to a character
</content>
</entry>
<entry>
<title>introduce hex2chr() for converting two hexadecimal digits to a character</title>
<updated>2016-09-07T17:42:46Z</updated>
<author>
<name>René Scharfe</name>
<email>l.s.r@web.de</email>
</author>
<published>2016-09-03T15:59:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d23309733a5b2a9e1adc304ee50c5a5ed7a087c2'/>
<id>urn:sha1:d23309733a5b2a9e1adc304ee50c5a5ed7a087c2</id>
<content type='text'>
Add and use a helper function that decodes the char value of two
hexadecimal digits.  It returns a negative number on error, avoids
running over the end of the given string and doesn't shift negative
values.

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>hex: add oid_to_hex_r()</title>
<updated>2016-06-28T18:39:02Z</updated>
<author>
<name>brian m. carlson</name>
<email>sandals@crustytoothpaste.net</email>
</author>
<published>2016-06-24T23:09:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=55c529a7005c653ceb318e1e25b40ff96a41877f'/>
<id>urn:sha1:55c529a7005c653ceb318e1e25b40ff96a41877f</id>
<content type='text'>
This function works just like sha1_to_hex_r, except that it takes a
pointer to struct object_id instead of a pointer to unsigned char.

Signed-off-by: brian m. carlson &lt;sandals@crustytoothpaste.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>add reentrant variants of sha1_to_hex and find_unique_abbrev</title>
<updated>2015-09-25T17:18:18Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2015-09-24T21:05:45Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=af49c6d0918bf04aad89bd885a4eef5767a33d0e'/>
<id>urn:sha1:af49c6d0918bf04aad89bd885a4eef5767a33d0e</id>
<content type='text'>
The sha1_to_hex and find_unique_abbrev functions always
write into reusable static buffers. There are a few problems
with this:

  - future calls overwrite our result. This is especially
    annoying with find_unique_abbrev, which does not have a
    ring of buffers, so you cannot even printf() a result
    that has two abbreviated sha1s.

  - if you want to put the result into another buffer, we
    often strcpy, which looks suspicious when auditing for
    overflows.

This patch introduces sha1_to_hex_r and find_unique_abbrev_r,
which write into a user-provided buffer. Of course this is
just punting on the overflow-auditing, as the buffer
obviously needs to be GIT_SHA1_HEXSZ + 1 bytes. But it is
much easier to audit, since that is a well-known size.

We retain the non-reentrant forms, which just become thin
wrappers around the reentrant ones. This patch also adds a
strbuf variant of find_unique_abbrev, which will be handy in
later patches.

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