diff options
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | shared.c | 5 | ||||
-rw-r--r-- | ui-blob.c | 6 | ||||
-rw-r--r-- | ui-commit.c | 2 | ||||
-rw-r--r-- | ui-diff.c | 4 | ||||
-rw-r--r-- | ui-log.c | 2 | ||||
-rw-r--r-- | ui-patch.c | 4 | ||||
-rw-r--r-- | ui-plain.c | 2 | ||||
-rw-r--r-- | ui-shared.c | 8 | ||||
-rw-r--r-- | ui-snapshot.c | 10 | ||||
-rw-r--r-- | ui-tag.c | 2 | ||||
-rw-r--r-- | ui-tree.c | 2 |
13 files changed, 29 insertions, 22 deletions
@@ -615,7 +615,7 @@ static int prepare_repo_cmd(void) return 1; } - if (get_sha1(ctx.qry.head, sha1)) { + if (cgit_get_sha1(ctx.qry.head, sha1)) { char *old_head = ctx.qry.head; ctx.qry.head = xstrdup(ctx.repo->defbranch); cgit_print_error_page(404, "Not found", @@ -391,4 +391,6 @@ extern char *expand_macros(const char *txt); extern char *get_mimetype_for_filename(const char *filename); +extern int cgit_get_sha1(const char *name, unsigned char *sha1); + #endif /* CGIT_H */ @@ -601,3 +601,8 @@ char *get_mimetype_for_filename(const char *filename) fclose(file); return NULL; } + +int cgit_get_sha1(const char *name, unsigned char *sha1) +{ + return get_sha1(name, sha1); +} @@ -52,7 +52,7 @@ int cgit_ref_path_exists(const char *path, const char *ref, int file_only) .file_only = file_only }; - if (get_sha1(ref, sha1)) + if (cgit_get_sha1(ref, sha1)) return 0; if (sha1_object_info(sha1, &size) != OBJ_COMMIT) return 0; @@ -82,7 +82,7 @@ int cgit_print_file(char *path, const char *head, int file_only) .file_only = file_only }; - if (get_sha1(head, sha1)) + if (cgit_get_sha1(head, sha1)) return -1; type = sha1_object_info(sha1, &size); if (type == OBJ_COMMIT) { @@ -132,7 +132,7 @@ void cgit_print_blob(const char *hex, char *path, const char *head, int file_onl return; } } else { - if (get_sha1(head, sha1)) { + if (cgit_get_sha1(head, sha1)) { cgit_print_error_page(404, "Not found", "Bad ref: %s", head); return; diff --git a/ui-commit.c b/ui-commit.c index 099d294..5ba0791 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -26,7 +26,7 @@ void cgit_print_commit(char *hex, const char *prefix) if (!hex) hex = ctx.qry.head; - if (get_sha1(hex, sha1)) { + if (cgit_get_sha1(hex, sha1)) { cgit_print_error_page(400, "Bad request", "Bad object id: %s", hex); return; @@ -402,7 +402,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_sha1(new_rev, new_rev_sha1)) { + if (cgit_get_sha1(new_rev, new_rev_sha1)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", new_rev); return; @@ -416,7 +416,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, new_tree_sha1 = commit->tree->object.oid.hash; if (old_rev) { - if (get_sha1(old_rev, old_rev_sha1)) { + if (cgit_get_sha1(old_rev, old_rev_sha1)) { cgit_print_error_page(404, "Not found", "Bad object name: %s", old_rev); return; @@ -325,7 +325,7 @@ static const char *disambiguate_ref(const char *ref, int *must_free_result) struct strbuf longref = STRBUF_INIT; strbuf_addf(&longref, "refs/heads/%s", ref); - if (get_sha1(longref.buf, oid.hash) == 0) { + if (cgit_get_sha1(longref.buf, oid.hash) == 0) { *must_free_result = 1; return strbuf_detach(&longref, NULL); } @@ -24,7 +24,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!new_rev) new_rev = ctx.qry.head; - if (get_sha1(new_rev, new_rev_sha1)) { + if (cgit_get_sha1(new_rev, new_rev_sha1)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", new_rev); return; @@ -37,7 +37,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, } if (old_rev) { - if (get_sha1(old_rev, old_rev_sha1)) { + if (cgit_get_sha1(old_rev, old_rev_sha1)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", old_rev); return; @@ -181,7 +181,7 @@ void cgit_print_plain(void) if (!rev) rev = ctx.qry.head; - if (get_sha1(rev, sha1)) { + if (cgit_get_sha1(rev, sha1)) { cgit_print_error_page(404, "Not found", "Not found"); return; } diff --git a/ui-shared.c b/ui-shared.c index e39d004..ca40d42 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1079,11 +1079,11 @@ void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base, * name starts with {v,V}[0-9] and the prettify mapping is injective, * i.e. each stripped tag can be inverted without ambiguities. */ - if (get_sha1(fmt("refs/tags/%s", ref), sha1) == 0 && + if (cgit_get_sha1(fmt("refs/tags/%s", ref), sha1) == 0 && (ref[0] == 'v' || ref[0] == 'V') && isdigit(ref[1]) && - ((get_sha1(fmt("refs/tags/%s", ref + 1), sha1) == 0) + - (get_sha1(fmt("refs/tags/v%s", ref + 1), sha1) == 0) + - (get_sha1(fmt("refs/tags/V%s", ref + 1), sha1) == 0) == 1)) + ((cgit_get_sha1(fmt("refs/tags/%s", ref + 1), sha1) == 0) + + (cgit_get_sha1(fmt("refs/tags/v%s", ref + 1), sha1) == 0) + + (cgit_get_sha1(fmt("refs/tags/V%s", ref + 1), sha1) == 0) == 1)) ref++; strbuf_addf(filename, "%s-%s", base, ref); diff --git a/ui-snapshot.c b/ui-snapshot.c index c6c3656..93af28e 100644 --- a/ui-snapshot.c +++ b/ui-snapshot.c @@ -111,7 +111,7 @@ static int make_snapshot(const struct cgit_snapshot_format *format, { unsigned char sha1[20]; - if (get_sha1(hex, sha1)) { + if (cgit_get_sha1(hex, sha1)) { cgit_print_error_page(404, "Not found", "Bad object id: %s", hex); return 1; @@ -150,7 +150,7 @@ static const char *get_ref_from_filename(const char *url, const char *filename, strbuf_addstr(&snapshot, filename); strbuf_setlen(&snapshot, snapshot.len - strlen(format->suffix)); - if (get_sha1(snapshot.buf, sha1) == 0) + if (cgit_get_sha1(snapshot.buf, sha1) == 0) goto out; reponame = cgit_repobasename(url); @@ -162,15 +162,15 @@ static const char *get_ref_from_filename(const char *url, const char *filename, strbuf_splice(&snapshot, 0, new_start - snapshot.buf, "", 0); } - if (get_sha1(snapshot.buf, sha1) == 0) + if (cgit_get_sha1(snapshot.buf, sha1) == 0) goto out; strbuf_insert(&snapshot, 0, "v", 1); - if (get_sha1(snapshot.buf, sha1) == 0) + if (cgit_get_sha1(snapshot.buf, sha1) == 0) goto out; strbuf_splice(&snapshot, 0, 1, "V", 1); - if (get_sha1(snapshot.buf, sha1) == 0) + if (cgit_get_sha1(snapshot.buf, sha1) == 0) goto out; result = 0; @@ -51,7 +51,7 @@ void cgit_print_tag(char *revname) revname = ctx.qry.head; strbuf_addf(&fullref, "refs/tags/%s", revname); - if (get_sha1(fullref.buf, sha1)) { + if (cgit_get_sha1(fullref.buf, sha1)) { cgit_print_error_page(404, "Not found", "Bad tag reference: %s", revname); goto cleanup; @@ -306,7 +306,7 @@ void cgit_print_tree(const char *rev, char *path) if (!rev) rev = ctx.qry.head; - if (get_sha1(rev, sha1)) { + if (cgit_get_sha1(rev, sha1)) { cgit_print_error_page(404, "Not found", "Invalid revision name: %s", rev); return; |