1 /* ui-shared.c: common web output functions
3 * Copyright (C) 2006-2014 cgit Development Team <cgit@lists.zx2c4.com>
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
10 #include "ui-shared.h"
14 const char cgit_doctype[] =
15 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n"
16 " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
18 static char *http_date(time_t t)
20 static char day[][4] =
21 {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
22 static char month[][4] =
23 {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
24 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
25 struct tm *tm = gmtime(&t);
26 return fmt("%s, %02d %s %04d %02d:%02d:%02d GMT", day[tm->tm_wday],
27 tm->tm_mday, month[tm->tm_mon], 1900 + tm->tm_year,
28 tm->tm_hour, tm->tm_min, tm->tm_sec);
31 void cgit_print_error(const char *fmt, ...)
35 cgit_vprint_error(fmt, ap);
39 void cgit_vprint_error(const char *fmt, va_list ap)
42 html("<div class='error'>");
49 const char *cgit_httpscheme()
51 if (ctx.env.https && !strcmp(ctx.env.https, "on"))
57 const char *cgit_hosturl()
59 if (ctx.env.http_host)
60 return ctx.env.http_host;
61 if (!ctx.env.server_name)
63 if (!ctx.env.server_port || atoi(ctx.env.server_port) == 80)
64 return ctx.env.server_name;
65 return fmtalloc("%s:%s", ctx.env.server_name, ctx.env.server_port);
68 const char *cgit_rooturl()
70 if (ctx.cfg.virtual_root)
71 return ctx.cfg.virtual_root;
73 return ctx.cfg.script_name;
76 char *cgit_repourl(const char *reponame)
78 if (ctx.cfg.virtual_root)
79 return fmtalloc("%s%s/", ctx.cfg.virtual_root, reponame);
81 return fmtalloc("?r=%s", reponame);
84 char *cgit_fileurl(const char *reponame, const char *pagename,
85 const char *filename, const char *query)
87 struct strbuf sb = STRBUF_INIT;
90 if (ctx.cfg.virtual_root) {
91 strbuf_addf(&sb, "%s%s/%s/%s", ctx.cfg.virtual_root, reponame,
92 pagename, (filename ? filename:""));
95 strbuf_addf(&sb, "?url=%s/%s/%s", reponame, pagename,
96 (filename ? filename : ""));
100 strbuf_addf(&sb, "%s%s", delim, query);
101 return strbuf_detach(&sb, NULL);
104 char *cgit_pageurl(const char *reponame, const char *pagename,
107 return cgit_fileurl(reponame, pagename, 0, query);
110 const char *cgit_repobasename(const char *reponame)
112 /* I assume we don't need to store more than one repo basename */
113 static char rvbuf[1024];
116 strncpy(rvbuf, reponame, sizeof(rvbuf));
117 if (rvbuf[sizeof(rvbuf)-1])
118 die("cgit_repobasename: truncated repository name '%s'", reponame);
120 /* strip trailing slashes */
121 while (p && rvbuf[p] == '/') rvbuf[p--] = 0;
122 /* strip trailing .git */
123 if (p >= 3 && !prefixcmp(&rvbuf[p-3], ".git")) {
124 p -= 3; rvbuf[p--] = 0;
126 /* strip more trailing slashes if any */
127 while ( p && rvbuf[p] == '/') rvbuf[p--] = 0;
128 /* find last slash in the remaining string */
129 rv = strrchr(rvbuf,'/');
135 static void site_url(const char *page, const char *search, const char *sort, int ofs)
139 if (ctx.cfg.virtual_root)
140 html_attr(ctx.cfg.virtual_root);
142 html_url_path(ctx.cfg.script_name);
145 htmlf("?p=%s", page);
162 htmlf("ofs=%d", ofs);
166 static void site_link(const char *page, const char *name, const char *title,
167 const char *class, const char *search, const char *sort, int ofs)
181 site_url(page, search, sort, ofs);
187 void cgit_index_link(const char *name, const char *title, const char *class,
188 const char *pattern, const char *sort, int ofs)
190 site_link(NULL, name, title, class, pattern, sort, ofs);
193 static char *repolink(const char *title, const char *class, const char *page,
194 const char *head, const char *path)
210 if (ctx.cfg.virtual_root) {
211 html_url_path(ctx.cfg.virtual_root);
212 html_url_path(ctx.repo->url);
213 if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
222 html_url_path(ctx.cfg.script_name);
224 html_url_arg(ctx.repo->url);
225 if (ctx.repo->url[strlen(ctx.repo->url) - 1] != '/')
235 if (head && strcmp(head, ctx.repo->defbranch)) {
241 return fmt("%s", delim);
244 static void reporevlink(const char *page, const char *name, const char *title,
245 const char *class, const char *head, const char *rev,
250 delim = repolink(title, class, page, head, path);
251 if (rev && ctx.qry.head != NULL && strcmp(rev, ctx.qry.head)) {
261 void cgit_summary_link(const char *name, const char *title, const char *class,
264 reporevlink(NULL, name, title, class, head, NULL, NULL);
267 void cgit_tag_link(const char *name, const char *title, const char *class,
268 const char *head, const char *rev)
270 reporevlink("tag", name, title, class, head, rev, NULL);
273 void cgit_tree_link(const char *name, const char *title, const char *class,
274 const char *head, const char *rev, const char *path)
276 reporevlink("tree", name, title, class, head, rev, path);
279 void cgit_plain_link(const char *name, const char *title, const char *class,
280 const char *head, const char *rev, const char *path)
282 reporevlink("plain", name, title, class, head, rev, path);
285 void cgit_log_link(const char *name, const char *title, const char *class,
286 const char *head, const char *rev, const char *path,
287 int ofs, const char *grep, const char *pattern, int showmsg)
291 delim = repolink(title, class, "log", head, path);
292 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
298 if (grep && pattern) {
305 html_url_arg(pattern);
322 void cgit_commit_link(char *name, const char *title, const char *class,
323 const char *head, const char *rev, const char *path,
326 if (strlen(name) > ctx.cfg.max_msg_len && ctx.cfg.max_msg_len >= 15) {
327 name[ctx.cfg.max_msg_len] = '\0';
328 name[ctx.cfg.max_msg_len - 1] = '.';
329 name[ctx.cfg.max_msg_len - 2] = '.';
330 name[ctx.cfg.max_msg_len - 3] = '.';
335 delim = repolink(title, class, "commit", head, path);
336 if (rev && ctx.qry.head && strcmp(rev, ctx.qry.head)) {
342 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
347 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
350 htmlf("%d", ctx.qry.context);
353 if (ctx.qry.ignorews) {
362 html_txt("(no commit message)");
366 void cgit_refs_link(const char *name, const char *title, const char *class,
367 const char *head, const char *rev, const char *path)
369 reporevlink("refs", name, title, class, head, rev, path);
372 void cgit_snapshot_link(const char *name, const char *title, const char *class,
373 const char *head, const char *rev,
374 const char *archivename)
376 reporevlink("snapshot", name, title, class, head, rev, archivename);
379 void cgit_diff_link(const char *name, const char *title, const char *class,
380 const char *head, const char *new_rev, const char *old_rev,
381 const char *path, int toggle_ssdiff)
385 delim = repolink(title, class, "diff", head, path);
386 if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
389 html_url_arg(new_rev);
395 html_url_arg(old_rev);
398 if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
403 if (ctx.qry.context > 0 && ctx.qry.context != 3) {
406 htmlf("%d", ctx.qry.context);
409 if (ctx.qry.ignorews) {
419 void cgit_patch_link(const char *name, const char *title, const char *class,
420 const char *head, const char *rev, const char *path)
422 reporevlink("patch", name, title, class, head, rev, path);
425 void cgit_stats_link(const char *name, const char *title, const char *class,
426 const char *head, const char *path)
428 reporevlink("stats", name, title, class, head, NULL, path);
431 static void cgit_self_link(char *name, const char *title, const char *class,
432 struct cgit_context *ctx)
434 if (!strcmp(ctx->qry.page, "repolist"))
435 cgit_index_link(name, title, class, ctx->qry.search, ctx->qry.sort,
437 else if (!strcmp(ctx->qry.page, "summary"))
438 cgit_summary_link(name, title, class, ctx->qry.head);
439 else if (!strcmp(ctx->qry.page, "tag"))
440 cgit_tag_link(name, title, class, ctx->qry.head,
441 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
442 else if (!strcmp(ctx->qry.page, "tree"))
443 cgit_tree_link(name, title, class, ctx->qry.head,
444 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
446 else if (!strcmp(ctx->qry.page, "plain"))
447 cgit_plain_link(name, title, class, ctx->qry.head,
448 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
450 else if (!strcmp(ctx->qry.page, "log"))
451 cgit_log_link(name, title, class, ctx->qry.head,
452 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
453 ctx->qry.path, ctx->qry.ofs,
454 ctx->qry.grep, ctx->qry.search,
456 else if (!strcmp(ctx->qry.page, "commit"))
457 cgit_commit_link(name, title, class, ctx->qry.head,
458 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
460 else if (!strcmp(ctx->qry.page, "patch"))
461 cgit_patch_link(name, title, class, ctx->qry.head,
462 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
464 else if (!strcmp(ctx->qry.page, "refs"))
465 cgit_refs_link(name, title, class, ctx->qry.head,
466 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
468 else if (!strcmp(ctx->qry.page, "snapshot"))
469 cgit_snapshot_link(name, title, class, ctx->qry.head,
470 ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
472 else if (!strcmp(ctx->qry.page, "diff"))
473 cgit_diff_link(name, title, class, ctx->qry.head,
474 ctx->qry.sha1, ctx->qry.sha2,
476 else if (!strcmp(ctx->qry.page, "stats"))
477 cgit_stats_link(name, title, class, ctx->qry.head,
480 /* Don't known how to make link for this page */
481 repolink(title, class, ctx->qry.page, ctx->qry.head, ctx->qry.path);
482 html("><!-- cgit_self_link() doesn't know how to make link for page '");
483 html_txt(ctx->qry.page);
490 void cgit_object_link(struct object *obj)
492 char *page, *shortrev, *fullrev, *name;
494 fullrev = sha1_to_hex(obj->sha1);
495 shortrev = xstrdup(fullrev);
497 if (obj->type == OBJ_COMMIT) {
498 cgit_commit_link(fmt("commit %s...", shortrev), NULL, NULL,
499 ctx.qry.head, fullrev, NULL, 0);
501 } else if (obj->type == OBJ_TREE)
503 else if (obj->type == OBJ_TAG)
507 name = fmt("%s %s...", typename(obj->type), shortrev);
508 reporevlink(page, name, NULL, NULL, ctx.qry.head, fullrev, NULL);
511 static struct string_list_item *lookup_path(struct string_list *list,
514 struct string_list_item *item;
516 while (path && path[0]) {
517 if ((item = string_list_lookup(list, path)))
519 if (!(path = strchr(path, '/')))
526 void cgit_submodule_link(const char *class, char *path, const char *rev)
528 struct string_list *list;
529 struct string_list_item *item;
535 list = &ctx.repo->submodules;
536 item = lookup_path(list, path);
539 tail = path[len - 1];
542 item = lookup_path(list, path);
547 htmlf("class='%s' ", class);
550 html_attrf(item->util, rev);
551 } else if (ctx.repo->module_link) {
552 dir = strrchr(path, '/');
557 html_attrf(ctx.repo->module_link, dir, rev);
564 html_txtf(" @ %.7s", rev);
566 path[len - 1] = tail;
569 void cgit_print_date(time_t secs, const char *format, int local_time)
577 time = localtime(&secs);
579 time = gmtime(&secs);
580 strftime(buf, sizeof(buf)-1, format, time);
584 void cgit_print_age(time_t t, time_t max_relative, const char *format)
593 if (secs > max_relative && max_relative >= 0) {
594 cgit_print_date(t, format, ctx.cfg.local_time);
598 if (secs < TM_HOUR * 2) {
599 htmlf("<span class='age-mins'>%.0f min.</span>",
600 secs * 1.0 / TM_MIN);
603 if (secs < TM_DAY * 2) {
604 htmlf("<span class='age-hours'>%.0f hours</span>",
605 secs * 1.0 / TM_HOUR);
608 if (secs < TM_WEEK * 2) {
609 htmlf("<span class='age-days'>%.0f days</span>",
610 secs * 1.0 / TM_DAY);
613 if (secs < TM_MONTH * 2) {
614 htmlf("<span class='age-weeks'>%.0f weeks</span>",
615 secs * 1.0 / TM_WEEK);
618 if (secs < TM_YEAR * 2) {
619 htmlf("<span class='age-months'>%.0f months</span>",
620 secs * 1.0 / TM_MONTH);
623 htmlf("<span class='age-years'>%.0f years</span>",
624 secs * 1.0 / TM_YEAR);
627 void cgit_print_http_headers(struct cgit_context *ctx)
629 if (ctx->env.no_http && !strcmp(ctx->env.no_http, "1"))
632 if (ctx->page.status)
633 htmlf("Status: %d %s\n", ctx->page.status, ctx->page.statusmsg);
634 if (ctx->page.mimetype && ctx->page.charset)
635 htmlf("Content-Type: %s; charset=%s\n", ctx->page.mimetype,
637 else if (ctx->page.mimetype)
638 htmlf("Content-Type: %s\n", ctx->page.mimetype);
640 htmlf("Content-Length: %zd\n", ctx->page.size);
641 if (ctx->page.filename)
642 htmlf("Content-Disposition: inline; filename=\"%s\"\n",
644 if (!ctx->env.authenticated)
645 html("Cache-Control: no-cache, no-store\n");
646 htmlf("Last-Modified: %s\n", http_date(ctx->page.modified));
647 htmlf("Expires: %s\n", http_date(ctx->page.expires));
649 htmlf("ETag: \"%s\"\n", ctx->page.etag);
651 if (ctx->env.request_method && !strcmp(ctx->env.request_method, "HEAD"))
655 void cgit_print_docstart(struct cgit_context *ctx)
657 if (ctx->cfg.embedded) {
659 html_include(ctx->cfg.header);
663 const char *host = cgit_hosturl();
665 html("<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>\n");
668 html_txt(ctx->page.title);
670 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
671 if (ctx->cfg.robots && *ctx->cfg.robots)
672 htmlf("<meta name='robots' content='%s'/>\n", ctx->cfg.robots);
673 html("<link rel='stylesheet' type='text/css' href='");
674 html_attr(ctx->cfg.css);
676 if (ctx->cfg.favicon) {
677 html("<link rel='shortcut icon' href='");
678 html_attr(ctx->cfg.favicon);
681 if (host && ctx->repo && ctx->qry.head) {
682 struct strbuf sb = STRBUF_INIT;
683 strbuf_addf(&sb, "h=%s", ctx->qry.head);
685 html("<link rel='alternate' title='Atom feed' href='");
686 html(cgit_httpscheme());
687 html_attr(cgit_hosturl());
688 html_attr(cgit_fileurl(ctx->repo->url, "atom", ctx->qry.vpath,
690 html("' type='application/atom+xml'/>\n");
693 if (ctx->cfg.head_include)
694 html_include(ctx->cfg.head_include);
698 html_include(ctx->cfg.header);
701 void cgit_print_docend()
703 html("</div> <!-- class=content -->\n");
704 if (ctx.cfg.embedded) {
705 html("</div> <!-- id=cgit -->\n");
707 html_include(ctx.cfg.footer);
711 html_include(ctx.cfg.footer);
713 htmlf("<div class='footer'>generated by cgit %s at ",
715 cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);
718 html("</div> <!-- id=cgit -->\n");
719 html("</body>\n</html>\n");
722 static int print_branch_option(const char *refname, const unsigned char *sha1,
723 int flags, void *cb_data)
725 char *name = (char *)refname;
726 html_option(name, name, ctx.qry.head);
730 void cgit_add_hidden_formfields(int incl_head, int incl_search,
733 if (!ctx.cfg.virtual_root) {
734 struct strbuf url = STRBUF_INIT;
736 strbuf_addf(&url, "%s/%s", ctx.qry.repo, page);
738 strbuf_addf(&url, "/%s", ctx.qry.vpath);
739 html_hidden("url", url.buf);
740 strbuf_release(&url);
743 if (incl_head && ctx.qry.head && ctx.repo->defbranch &&
744 strcmp(ctx.qry.head, ctx.repo->defbranch))
745 html_hidden("h", ctx.qry.head);
748 html_hidden("id", ctx.qry.sha1);
750 html_hidden("id2", ctx.qry.sha2);
752 html_hidden("showmsg", "1");
756 html_hidden("qt", ctx.qry.grep);
758 html_hidden("q", ctx.qry.search);
762 static const char *hc(struct cgit_context *ctx, const char *page)
764 return strcmp(ctx->qry.page, page) ? NULL : "active";
767 static void cgit_print_path_crumbs(struct cgit_context *ctx, char *path)
769 char *old_path = ctx->qry.path;
770 char *p = path, *q, *end = path + strlen(path);
772 ctx->qry.path = NULL;
773 cgit_self_link("root", NULL, NULL, ctx);
774 ctx->qry.path = p = path;
776 if (!(q = strchr(p, '/')))
780 cgit_self_link(p, NULL, NULL, ctx);
785 ctx->qry.path = old_path;
788 static void print_header(struct cgit_context *ctx)
790 char *logo = NULL, *logo_link = NULL;
792 html("<table id='header'>\n");
795 if (ctx->repo && ctx->repo->logo && *ctx->repo->logo)
796 logo = ctx->repo->logo;
798 logo = ctx->cfg.logo;
799 if (ctx->repo && ctx->repo->logo_link && *ctx->repo->logo_link)
800 logo_link = ctx->repo->logo_link;
802 logo_link = ctx->cfg.logo_link;
804 html("<td class='logo' rowspan='2'><a href='");
805 if (logo_link && *logo_link)
806 html_attr(logo_link);
808 html_attr(cgit_rooturl());
809 html("'><img src='");
811 html("' alt='cgit logo'/></a></td>\n");
814 html("<td class='main'>");
816 cgit_index_link("index", NULL, NULL, NULL, NULL, 0);
818 cgit_summary_link(ctx->repo->name, ctx->repo->name, NULL, NULL);
819 if (ctx->env.authenticated) {
820 html("</td><td class='form'>");
821 html("<form method='get' action=''>\n");
822 cgit_add_hidden_formfields(0, 1, ctx->qry.page);
823 html("<select name='h' onchange='this.form.submit();'>\n");
824 for_each_branch_ref(print_branch_option, ctx->qry.head);
826 html("<input type='submit' name='' value='switch'/>");
830 html_txt(ctx->cfg.root_title);
831 html("</td></tr>\n");
833 html("<tr><td class='sub'>");
835 html_txt(ctx->repo->desc);
836 html("</td><td class='sub right'>");
837 html_txt(ctx->repo->owner);
839 if (ctx->cfg.root_desc)
840 html_txt(ctx->cfg.root_desc);
841 else if (ctx->cfg.index_info)
842 html_include(ctx->cfg.index_info);
844 html("</td></tr></table>\n");
847 void cgit_print_pageheader(struct cgit_context *ctx)
849 html("<div id='cgit'>");
850 if (!ctx->env.authenticated || !ctx->cfg.noheader)
853 html("<table class='tabs'><tr><td>\n");
854 if (ctx->env.authenticated && ctx->repo) {
855 cgit_summary_link("summary", NULL, hc(ctx, "summary"),
857 cgit_refs_link("refs", NULL, hc(ctx, "refs"), ctx->qry.head,
858 ctx->qry.sha1, NULL);
859 cgit_log_link("log", NULL, hc(ctx, "log"), ctx->qry.head,
860 NULL, ctx->qry.vpath, 0, NULL, NULL,
862 cgit_tree_link("tree", NULL, hc(ctx, "tree"), ctx->qry.head,
863 ctx->qry.sha1, ctx->qry.vpath);
864 cgit_commit_link("commit", NULL, hc(ctx, "commit"),
865 ctx->qry.head, ctx->qry.sha1, ctx->qry.vpath, 0);
866 cgit_diff_link("diff", NULL, hc(ctx, "diff"), ctx->qry.head,
867 ctx->qry.sha1, ctx->qry.sha2, ctx->qry.vpath, 0);
868 if (ctx->repo->max_stats)
869 cgit_stats_link("stats", NULL, hc(ctx, "stats"),
870 ctx->qry.head, ctx->qry.vpath);
871 if (ctx->repo->readme.nr)
872 reporevlink("about", "about", NULL,
873 hc(ctx, "about"), ctx->qry.head, NULL,
875 html("</td><td class='form'>");
876 html("<form class='right' method='get' action='");
877 if (ctx->cfg.virtual_root)
878 html_url_path(cgit_fileurl(ctx->qry.repo, "log",
879 ctx->qry.vpath, NULL));
881 cgit_add_hidden_formfields(1, 0, "log");
882 html("<select name='qt'>\n");
883 html_option("grep", "log msg", ctx->qry.grep);
884 html_option("author", "author", ctx->qry.grep);
885 html_option("committer", "committer", ctx->qry.grep);
886 html_option("range", "range", ctx->qry.grep);
888 html("<input class='txt' type='text' size='10' name='q' value='");
889 html_attr(ctx->qry.search);
891 html("<input type='submit' value='search'/>\n");
893 } else if (ctx->env.authenticated) {
894 site_link(NULL, "index", NULL, hc(ctx, "repolist"), NULL, NULL, 0);
895 if (ctx->cfg.root_readme)
896 site_link("about", "about", NULL, hc(ctx, "about"),
898 html("</td><td class='form'>");
899 html("<form method='get' action='");
900 html_attr(cgit_rooturl());
902 html("<input type='text' name='q' size='10' value='");
903 html_attr(ctx->qry.search);
905 html("<input type='submit' value='search'/>\n");
908 html("</td></tr></table>\n");
909 if (ctx->env.authenticated && ctx->qry.vpath) {
910 html("<div class='path'>");
912 cgit_print_path_crumbs(ctx, ctx->qry.vpath);
915 html("<div class='content'>");
918 void cgit_print_filemode(unsigned short mode)
922 else if (S_ISLNK(mode))
924 else if (S_ISGITLINK(mode))
928 html_fileperm(mode >> 6);
929 html_fileperm(mode >> 3);
933 void cgit_print_snapshot_links(const char *repo, const char *head,
934 const char *hex, int snapshots)
936 const struct cgit_snapshot_format* f;
937 struct strbuf filename = STRBUF_INIT;
939 unsigned char sha1[20];
941 if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
942 (hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
944 strbuf_addf(&filename, "%s-%s", cgit_repobasename(repo), hex);
945 prefixlen = filename.len;
946 for (f = cgit_snapshot_formats; f->suffix; f++) {
947 if (!(snapshots & f->bit))
949 strbuf_setlen(&filename, prefixlen);
950 strbuf_addstr(&filename, f->suffix);
951 cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL,
955 strbuf_release(&filename);