|
15 | 15 |
|
16 | 16 | #include "git2.h" |
17 | 17 |
|
18 | | -static int maybe_sha_or_abbrev(git_object **out, git_repository *repo, const char *spec, size_t speclen) |
| 18 | +static int maybe_sha_or_abbrev( |
| 19 | + git_object **out, |
| 20 | + git_repository *repo, |
| 21 | + const char *spec, |
| 22 | + size_t speclen) |
19 | 23 | { |
20 | 24 | git_oid oid; |
21 | 25 |
|
22 | | - if (git_oid__fromstrn(&oid, spec, speclen, GIT_OID_SHA1) < 0) |
| 26 | + if (git_oid__fromstrn(&oid, spec, speclen, repo->oid_type) < 0) |
23 | 27 | return GIT_ENOTFOUND; |
24 | 28 |
|
25 | 29 | return git_object_lookup_prefix(out, repo, &oid, speclen, GIT_OBJECT_ANY); |
26 | 30 | } |
27 | 31 |
|
28 | | -static int maybe_sha(git_object **out, git_repository *repo, const char *spec) |
| 32 | +static int maybe_sha( |
| 33 | + git_object **out, |
| 34 | + git_repository *repo, |
| 35 | + const char *spec) |
29 | 36 | { |
30 | 37 | size_t speclen = strlen(spec); |
31 | 38 |
|
32 | | - if (speclen != GIT_OID_SHA1_HEXSIZE) |
| 39 | + if (speclen != git_oid_hexsize(repo->oid_type)) |
33 | 40 | return GIT_ENOTFOUND; |
34 | 41 |
|
35 | 42 | return maybe_sha_or_abbrev(out, repo, spec, speclen); |
@@ -110,8 +117,8 @@ static int revparse_lookup_object( |
110 | 117 | if (error != GIT_ENOTFOUND) |
111 | 118 | return error; |
112 | 119 |
|
113 | | - if ((strlen(spec) < GIT_OID_SHA1_HEXSIZE) && |
114 | | - ((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND)) |
| 120 | + if ((strlen(spec) < git_oid_hexsize(repo->oid_type)) && |
| 121 | + ((error = maybe_abbrev(object_out, repo, spec)) != GIT_ENOTFOUND)) |
115 | 122 | return error; |
116 | 123 |
|
117 | 124 | if ((error = maybe_describe(object_out, repo, spec)) != GIT_ENOTFOUND) |
|
0 commit comments