|
13 | 13 | #include "string-list.h"
|
14 | 14 | #include "pack-revindex.h"
|
15 | 15 | #include "hash.h"
|
| 16 | +#include "hex.h" |
16 | 17 | #include "path.h"
|
17 | 18 | #include "oid-array.h"
|
18 | 19 | #include "repository.h"
|
@@ -1325,22 +1326,6 @@ int finalize_object_file(const char *tmpfile, const char *filename);
|
1325 | 1326 | /* Helper to check and "touch" a file */
|
1326 | 1327 | int check_and_freshen_file(const char *fn, int freshen);
|
1327 | 1328 |
|
1328 |
| -extern const signed char hexval_table[256]; |
1329 |
| -static inline unsigned int hexval(unsigned char c) |
1330 |
| -{ |
1331 |
| - return hexval_table[c]; |
1332 |
| -} |
1333 |
| - |
1334 |
| -/* |
1335 |
| - * Convert two consecutive hexadecimal digits into a char. Return a |
1336 |
| - * negative value on error. Don't run over the end of short strings. |
1337 |
| - */ |
1338 |
| -static inline int hex2chr(const char *s) |
1339 |
| -{ |
1340 |
| - unsigned int val = hexval(s[0]); |
1341 |
| - return (val & ~0xf) ? val : (val << 4) | hexval(s[1]); |
1342 |
| -} |
1343 |
| - |
1344 | 1329 | /* Convert to/from hex/sha1 representation */
|
1345 | 1330 | #define MINIMUM_ABBREV minimum_abbrev
|
1346 | 1331 | #define DEFAULT_ABBREV default_abbrev
|
@@ -1393,68 +1378,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_f
|
1393 | 1378 |
|
1394 | 1379 | int set_disambiguate_hint_config(const char *var, const char *value);
|
1395 | 1380 |
|
1396 |
| -/* |
1397 |
| - * Try to read a SHA1 in hexadecimal format from the 40 characters |
1398 |
| - * starting at hex. Write the 20-byte result to sha1 in binary form. |
1399 |
| - * Return 0 on success. Reading stops if a NUL is encountered in the |
1400 |
| - * input, so it is safe to pass this function an arbitrary |
1401 |
| - * null-terminated string. |
1402 |
| - */ |
1403 |
| -int get_sha1_hex(const char *hex, unsigned char *sha1); |
1404 |
| -int get_oid_hex(const char *hex, struct object_id *sha1); |
1405 |
| - |
1406 |
| -/* Like get_oid_hex, but for an arbitrary hash algorithm. */ |
1407 |
| -int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop); |
1408 |
| - |
1409 |
| -/* |
1410 |
| - * Read `len` pairs of hexadecimal digits from `hex` and write the |
1411 |
| - * values to `binary` as `len` bytes. Return 0 on success, or -1 if |
1412 |
| - * the input does not consist of hex digits). |
1413 |
| - */ |
1414 |
| -int hex_to_bytes(unsigned char *binary, const char *hex, size_t len); |
1415 |
| - |
1416 |
| -/* |
1417 |
| - * Convert a binary hash in "unsigned char []" or an object name in |
1418 |
| - * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant, |
1419 |
| - * and writes the NUL-terminated output to the buffer `out`, which must be at |
1420 |
| - * least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for |
1421 |
| - * convenience. |
1422 |
| - * |
1423 |
| - * The non-`_r` variant returns a static buffer, but uses a ring of 4 |
1424 |
| - * buffers, making it safe to make multiple calls for a single statement, like: |
1425 |
| - * |
1426 |
| - * printf("%s -> %s", hash_to_hex(one), hash_to_hex(two)); |
1427 |
| - * printf("%s -> %s", oid_to_hex(one), oid_to_hex(two)); |
1428 |
| - */ |
1429 |
| -char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *); |
1430 |
| -char *oid_to_hex_r(char *out, const struct object_id *oid); |
1431 |
| -char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */ |
1432 |
| -char *hash_to_hex(const unsigned char *hash); /* same static buffer */ |
1433 |
| -char *oid_to_hex(const struct object_id *oid); /* same static buffer */ |
1434 |
| - |
1435 |
| -/* |
1436 |
| - * Parse a 40-character hexadecimal object ID starting from hex, updating the |
1437 |
| - * pointer specified by end when parsing stops. The resulting object ID is |
1438 |
| - * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or |
1439 |
| - * other invalid character. end is only updated on success; otherwise, it is |
1440 |
| - * unmodified. |
1441 |
| - */ |
1442 |
| -int parse_oid_hex(const char *hex, struct object_id *oid, const char **end); |
1443 |
| - |
1444 |
| -/* Like parse_oid_hex, but for an arbitrary hash algorithm. */ |
1445 |
| -int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end, |
1446 |
| - const struct git_hash_algo *algo); |
1447 |
| - |
1448 |
| - |
1449 |
| -/* |
1450 |
| - * These functions work like get_oid_hex and parse_oid_hex, but they will parse |
1451 |
| - * a hex value for any algorithm. The algorithm is detected based on the length |
1452 |
| - * and the algorithm in use is returned. If this is not a hex object ID in any |
1453 |
| - * algorithm, returns GIT_HASH_UNKNOWN. |
1454 |
| - */ |
1455 |
| -int get_oid_hex_any(const char *hex, struct object_id *oid); |
1456 |
| -int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end); |
1457 |
| - |
1458 | 1381 | /*
|
1459 | 1382 | * This reads short-hand syntax that not only evaluates to a commit
|
1460 | 1383 | * object name, but also can act as if the end user spelled the name
|
|
0 commit comments