X-Git-Url: https://git.cameronkatri.com/cgit.git/blobdiff_plain/fe1bb0e765883fa4149fba12daee81b6ae070de3..71926bfb342b75a6721441b1fe9b9db8b50775d5:/ui-shared.c diff --git a/ui-shared.c b/ui-shared.c index 75b97a1..31224bc 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -23,7 +23,7 @@ static char *http_date(time_t t) "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); } @@ -93,7 +93,7 @@ char *cgit_fileurl(const char *reponame, const char *pagename, 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) @@ -102,37 +102,25 @@ 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 = "?"; @@ -433,8 +421,8 @@ void cgit_stats_link(const char *name, const char *title, const char *class, 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, @@ -499,7 +487,7 @@ void cgit_object_link(struct object *obj) 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) @@ -512,8 +500,8 @@ void cgit_object_link(struct object *obj) 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; @@ -564,6 +552,7 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) html("'>"); html_txt(path); html(""); + html_txt(fmt(" @ %.7s", rev)); if (item && tail) path[len - 1] = tail; } @@ -575,7 +564,7 @@ void cgit_print_date(time_t secs, const char *format, int local_time) if (!secs) return; - if(local_time) + if (local_time) time = localtime(&secs); else time = gmtime(&secs); @@ -715,16 +704,16 @@ void cgit_print_docend() html("\n\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; @@ -735,7 +724,7 @@ int print_archive_ref(const char *refname, const unsigned char *sha1, 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; @@ -967,7 +956,7 @@ void cgit_print_snapshot_links(const char *repo, const char *head, { 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 &&