Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.zx2c4.com/cgit.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgit.c2
-rw-r--r--cgit.h2
-rw-r--r--shared.c5
-rw-r--r--ui-blob.c6
-rw-r--r--ui-commit.c2
-rw-r--r--ui-diff.c4
-rw-r--r--ui-log.c2
-rw-r--r--ui-patch.c4
-rw-r--r--ui-plain.c2
-rw-r--r--ui-shared.c8
-rw-r--r--ui-snapshot.c10
-rw-r--r--ui-tag.c2
-rw-r--r--ui-tree.c2
13 files changed, 29 insertions, 22 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 c97b8e0..28ef3c0 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -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);
}
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 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;
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;