Skip to content

Commit 3365e26

Browse files
committed
Merge branch 'jc/retire-get-sha1-hex'
The implementation of "get_sha1_hex()" that reads a hexadecimal string that spells a full object name has been extended to cope with any hash function used in the repository, but the "sha1" in its name survived. Rename it to get_hash_hex(), a name that is more consistent within its friends like get_hash_hex_algop(). * jc/retire-get-sha1-hex: hex: retire get_sha1_hex()
2 parents dd68b57 + 08e5fb1 commit 3365e26

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

hex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static int get_hash_hex_algop(const char *hex, unsigned char *hash,
6363
return 0;
6464
}
6565

66-
int get_sha1_hex(const char *hex, unsigned char *sha1)
66+
int get_hash_hex(const char *hex, unsigned char *sha1)
6767
{
6868
return get_hash_hex_algop(hex, sha1, the_hash_algo);
6969
}

hex.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ static inline int hex2chr(const char *s)
2020
}
2121

2222
/*
23-
* Try to read a SHA1 in hexadecimal format from the 40 characters
24-
* starting at hex. Write the 20-byte result to sha1 in binary form.
23+
* Try to read a hash (specified by the_hash_algo) in hexadecimal
24+
* format from the 40 (or whatever length the hash algorithm uses)
25+
* characters starting at hex. Write the 20-byte (or the length of
26+
* the hash) result to hash in binary form.
2527
* Return 0 on success. Reading stops if a NUL is encountered in the
2628
* input, so it is safe to pass this function an arbitrary
2729
* null-terminated string.
2830
*/
29-
int get_sha1_hex(const char *hex, unsigned char *sha1);
30-
int get_oid_hex(const char *hex, struct object_id *sha1);
31+
int get_hash_hex(const char *hex, unsigned char *hash);
32+
int get_oid_hex(const char *hex, struct object_id *oid);
3133

3234
/* Like get_oid_hex, but for an arbitrary hash algorithm. */
3335
int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);

packfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
751751
p->pack_local = local;
752752
p->mtime = st.st_mtime;
753753
if (path_len < the_hash_algo->hexsz ||
754-
get_sha1_hex(path + path_len - the_hash_algo->hexsz, p->hash))
754+
get_hash_hex(path + path_len - the_hash_algo->hexsz, p->hash))
755755
hashclr(p->hash);
756756
return p;
757757
}

rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static void read_rr(struct repository *r, struct string_list *rr)
204204
const unsigned hexsz = the_hash_algo->hexsz;
205205

206206
/* There has to be the hash, tab, path and then NUL */
207-
if (buf.len < hexsz + 2 || get_sha1_hex(buf.buf, hash))
207+
if (buf.len < hexsz + 2 || get_hash_hex(buf.buf, hash))
208208
die(_("corrupt MERGE_RR"));
209209

210210
if (buf.buf[hexsz] != '.') {

0 commit comments

Comments
 (0)