Author: Christian Hesse <mail@eworm.de>
global: replace hard coded hash length With sha1 we had a guaranteed length of 40 hex chars. This changes now that we have to support sha256 with 64 hex chars... Support both. Signed-off-by: Christian Hesse <mail@eworm.de>
filters/commit-links.sh | 2 +- parsing.c | 5 ++--- tests/t0105-commit.sh | 2 +- ui-patch.c | 2 +-
diff --git a/filters/commit-links.sh b/filters/commit-links.sh index 58819524ced8eb8f99bec05cfd75f730c27307dc..796ac308d237b41d1eeb01e6cb3072180c6898a1 100755 --- a/filters/commit-links.sh +++ b/filters/commit-links.sh @@ -19,7 +19,7 @@ regex='' # This expression generates links to commits referenced by their SHA1. regex=$regex' -s|\b([0-9a-fA-F]{7,40})\b|<a href="./?id=\1">\1</a>|g' +s|\b([0-9a-fA-F]{7,64})\b|<a href="./?id=\1">\1</a>|g' # This expression generates links to a fictional bugtracker. regex=$regex' diff --git a/parsing.c b/parsing.c index e647dba018fd470578f570750ce70196c8d7682d..72b59b3c46a6c52aadd1134f215c8ce3f274d392 100644 --- a/parsing.c +++ b/parsing.c @@ -127,7 +127,6 @@ } struct commitinfo *cgit_parse_commit(struct commit *commit) { - const int oid_hex_len = 40; struct commitinfo *ret; const char *p = repo_get_commit_buffer(the_repository, commit, NULL); const char *t; @@ -140,10 +139,10 @@ return ret; if (!skip_prefix(p, "tree ", &p)) die("Bad commit: %s", oid_to_hex(&commit->object.oid)); - p += oid_hex_len + 1; + p += the_hash_algo->hexsz + 1; while (skip_prefix(p, "parent ", &p)) - p += oid_hex_len + 1; + p += the_hash_algo->hexsz + 1; if (p && skip_prefix(p, "author ", &p)) { parse_user(p, &ret->author, &ret->author_email, diff --git a/tests/t0105-commit.sh b/tests/t0105-commit.sh index 9cdf55c02576cbcd596afcd43e41a074e5611179..1a12ee39a9e7ba579c10f16f8e619033bd14cdf4 100755 --- a/tests/t0105-commit.sh +++ b/tests/t0105-commit.sh @@ -25,7 +25,7 @@ grep "