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",
extern char *get_mimetype_for_filename(const char *filename);
+extern int cgit_get_sha1(const char *name, unsigned char *sha1);
+
#endif /* CGIT_H */
fclose(file);
return NULL;
}
+
+int cgit_get_sha1(const char *name, unsigned char *sha1)
+{
+ return get_sha1(name, sha1);
+}
.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;
.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) {
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;
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;
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;
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;
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);
}
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;
}
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;
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;
}
* 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);
{
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;
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);
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;
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;
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;