char *cgit_currenturl(void)
{
- if (!ctx.qry.url)
- return xstrdup(cgit_rooturl());
const char *root = cgit_rooturl();
size_t len = strlen(root);
+
+ if (!ctx.qry.url)
+ return xstrdup(root);
if (len && root[len - 1] == '/')
return fmtalloc("%s%s", root, ctx.qry.url);
return fmtalloc("%s/%s", root, ctx.qry.url);
}
delim = "&";
}
- if (head && strcmp(head, ctx.repo->defbranch)) {
+ if (head && ctx.repo->defbranch && strcmp(head, ctx.repo->defbranch)) {
html(delim);
html("h=");
html_url_arg(head);
void cgit_commit_link(char *name, const char *title, const char *class,
const char *head, const char *rev, const char *path)
{
+ char *delim;
+
if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
name[ctx.cfg.max_msg_len] = '\0';
name[ctx.cfg.max_msg_len - 1] = '.';
name[ctx.cfg.max_msg_len - 3] = '.';
}
- char *delim;
-
delim = repolink(title, class, "commit", head, path);
if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
html(delim);
void cgit_print_docstart(void)
{
+ char *host = cgit_hosturl();
+
if (ctx.cfg.embedded) {
if (ctx.cfg.header)
html_include(ctx.cfg.header);
return;
}
- char *host = cgit_hosturl();
html(cgit_doctype);
html("<html lang='en'>\n");
html("<head>\n");
free(currenturl);
}
html("</td></tr></table>\n");
- if (ctx.env.authenticated && ctx.qry.vpath) {
+ if (ctx.env.authenticated && ctx.repo && ctx.qry.vpath) {
html("<div class='path'>");
html("path: ");
cgit_print_path_crumbs(ctx.qry.vpath);
void cgit_compose_snapshot_prefix(struct strbuf *filename, const char *base,
const char *ref)
{
- unsigned char sha1[20];
+ struct object_id oid;
/*
* Prettify snapshot names by stripping leading "v" or "V" if the tag
* 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 (get_oid(fmt("refs/tags/%s", ref), &oid) == 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))
+ ((get_oid(fmt("refs/tags/%s", ref + 1), &oid) == 0) +
+ (get_oid(fmt("refs/tags/v%s", ref + 1), &oid) == 0) +
+ (get_oid(fmt("refs/tags/V%s", ref + 1), &oid) == 0) == 1))
ref++;
strbuf_addf(filename, "%s-%s", base, ref);