"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
struct tm *tm = gmtime(&t);
return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
- tm->tm_mday, month[tm->tm_mon], 1900+tm->tm_year,
+ tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec);
}
} else {
tmp = fmt("?url=%s/%s/%s", reponame, pagename,
(filename ? filename : ""));
- delim = "&";
+ delim = "&";
}
if (query)
tmp = fmt("%s%s%s", tmp, delim, query);
char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query)
{
- return cgit_fileurl(reponame,pagename,0,query);
+ return cgit_fileurl(reponame, pagename, 0, query);
}
const char *cgit_repobasename(const char *reponame)
static char rvbuf[1024];
int p;
const char *rv;
- strncpy(rvbuf,reponame,sizeof(rvbuf));
- if(rvbuf[sizeof(rvbuf)-1])
+ strncpy(rvbuf, reponame, sizeof(rvbuf));
+ if (rvbuf[sizeof(rvbuf)-1])
die("cgit_repobasename: truncated repository name '%s'", reponame);
p = strlen(rvbuf)-1;
/* strip trailing slashes */
- while(p && rvbuf[p]=='/') rvbuf[p--]=0;
+ while (p && rvbuf[p] == '/') rvbuf[p--] = 0;
/* strip trailing .git */
- if(p>=3 && !strncmp(&rvbuf[p-3],".git",4)) {
+ if (p >= 3 && !strncmp(&rvbuf[p-3], ".git", 4)) {
p -= 3; rvbuf[p--] = 0;
}
/* strip more trailing slashes if any */
- while( p && rvbuf[p]=='/') rvbuf[p--]=0;
+ while ( p && rvbuf[p] == '/') rvbuf[p--] = 0;
/* find last slash in the remaining string */
rv = strrchr(rvbuf,'/');
- if(rv)
+ if (rv)
return ++rv;
return rvbuf;
}
-char *cgit_currurl()
-{
- if (!ctx.cfg.virtual_root)
- return ctx.cfg.script_name;
- else if (ctx.qry.page)
- return fmt("%s/%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo, ctx.qry.page);
- else if (ctx.qry.repo)
- return fmt("%s/%s/", ctx.cfg.virtual_root, ctx.qry.repo);
- else
- return fmt("%s/", ctx.cfg.virtual_root);
-}
-
static void site_url(const char *page, const char *search, const char *sort, int ofs)
{
char *delim = "?";
if (page) {
htmlf("?p=%s", page);
- delim = "&";
+ delim = "&";
}
if (search) {
html(delim);
html("q=");
html_attr(search);
- delim = "&";
+ delim = "&";
}
if (sort) {
html(delim);
html("s=");
html_attr(sort);
- delim = "&";
+ delim = "&";
}
if (ofs) {
html(delim);
html(delim);
html("id=");
html_url_arg(rev);
- delim = "&";
+ delim = "&";
}
if (grep && pattern) {
html(delim);
html("qt=");
html_url_arg(grep);
- delim = "&";
+ delim = "&";
html(delim);
html("q=");
html_url_arg(pattern);
html(delim);
html("ofs=");
htmlf("%d", ofs);
- delim = "&";
+ delim = "&";
}
if (showmsg) {
html(delim);
delim = "&";
}
html("'>");
- html_txt(name);
+ if (name[0] != '\0')
+ html_txt(name);
+ else
+ html_txt("(no commit message)");
html("</a>");
}
reporevlink("stats", name, title, class, head, NULL, path);
}
-void cgit_self_link(char *name, const char *title, const char *class,
- struct cgit_context *ctx)
+static void cgit_self_link(char *name, const char *title, const char *class,
+ struct cgit_context *ctx)
{
if (!strcmp(ctx->qry.page, "repolist"))
return cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort,
shortrev = xstrdup(fullrev);
shortrev[10] = '\0';
if (obj->type == OBJ_COMMIT) {
- cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
+ cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
ctx.qry.head, fullrev, NULL, 0);
return;
} else if (obj->type == OBJ_TREE)
reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
}
-struct string_list_item *lookup_path(struct string_list *list,
- const char *path)
+static struct string_list_item *lookup_path(struct string_list *list,
+ const char *path)
{
struct string_list_item *item;
html("'>");
html_txt(path);
html("</a>");
+ html_txt(fmt(" @ %.7s", rev));
if (item && tail)
path[len - 1] = tail;
}
if (!secs)
return;
- if(local_time)
+ if (local_time)
time = localtime(&secs);
else
time = gmtime(&secs);
html("</body>\n</html>\n");
}
-int print_branch_option(const char *refname, const unsigned char *sha1,
- int flags, void *cb_data)
+static int print_branch_option(const char *refname, const unsigned char *sha1,
+ int flags, void *cb_data)
{
char *name = (char *)refname;
html_option(name, name, ctx.qry.head);
return 0;
}
-int print_archive_ref(const char *refname, const unsigned char *sha1,
- int flags, void *cb_data)
+static int print_archive_ref(const char *refname, const unsigned char *sha1,
+ int flags, void *cb_data)
{
struct tag *tag;
struct taginfo *info;
if (prefixcmp(refname, "refs/archives"))
return 0;
- strncpy(buf, refname+14, sizeof(buf));
+ strncpy(buf, refname + 14, sizeof(buf));
obj = parse_object(sha1);
if (!obj)
return 1;
{
const struct cgit_snapshot_format* f;
char *prefix;
- char *filename;
+ char *filename;
unsigned char sha1[20];
if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&