This will later be changed to include namespace resolution,
but the call sites are changed now to keep the changes small.

Signed-off-by: Richard Maw <[email protected]>
---
 cgit.c        |  2 +-
 cgit.h        |  2 ++
 shared.c      |  5 +++++
 ui-blob.c     |  6 +++---
 ui-commit.c   |  2 +-
 ui-diff.c     |  4 ++--
 ui-log.c      |  2 +-
 ui-patch.c    |  4 ++--
 ui-plain.c    |  2 +-
 ui-shared.c   |  2 +-
 ui-snapshot.c | 10 +++++-----
 ui-tag.c      |  2 +-
 ui-tree.c     |  2 +-
 13 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/cgit.c b/cgit.c
index 9427c4a..94d452c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -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",
diff --git a/cgit.h b/cgit.h
index 325432b..49f0557 100644
--- a/cgit.h
+++ b/cgit.h
@@ -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 */
diff --git a/shared.c b/shared.c
index a63633b..d82c07b 100644
--- a/shared.c
+++ b/shared.c
@@ -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);
+}
diff --git a/ui-blob.c b/ui-blob.c
index d388489..21d21ed 100644
--- a/ui-blob.c
+++ b/ui-blob.c
@@ -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;
diff --git a/ui-diff.c b/ui-diff.c
index edee793..9256d12 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -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;
diff --git a/ui-log.c b/ui-log.c
index d6d94f6..d110988 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -324,7 +324,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);
        }
diff --git a/ui-patch.c b/ui-patch.c
index 4c051e8..ff09a8e 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -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;
diff --git a/ui-plain.c b/ui-plain.c
index 97cf639..88dd1a8 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -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 562fa0e..4e1c2ba 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -1077,7 +1077,7 @@ void cgit_print_snapshot_links(const char *repo, const 
char *head,
        size_t prefixlen;
        unsigned char sha1[20];
 
-       if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
+       if (cgit_get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
            (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
                hex++;
        strbuf_addf(&filename, "%s-%s", cgit_repobasename(repo), hex);
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;
diff --git a/ui-tag.c b/ui-tag.c
index 6b838cb..7372770 100644
--- a/ui-tag.c
+++ b/ui-tag.c
@@ -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;
diff --git a/ui-tree.c b/ui-tree.c
index 120066c..ae2acce 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -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;
-- 
2.9.0

_______________________________________________
CGit mailing list
[email protected]
http://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to