From: Lars Hjemli Date: Sun, 2 Dec 2007 21:28:37 +0000 (+0100) Subject: Merge branch 'stable' X-Git-Url: https://gitweb.ps.run/ps-cgit/commitdiff_plain/dabb34af760eff2a6ab8e14927fd173cafb77547?ds=sidebyside;hp=-c Merge branch 'stable' * stable: Handle missing timestamp in commit/tag objects Set commit date on snapshot contents --- dabb34af760eff2a6ab8e14927fd173cafb77547 diff --combined parsing.c index e8c7ab9,55a485d..5093b8b --- a/parsing.c +++ b/parsing.c @@@ -199,7 -199,6 +199,7 @@@ struct commitinfo *cgit_parse_commit(st ret->committer_email = NULL; ret->subject = NULL; ret->msg = NULL; + ret->msg_encoding = NULL; if (p == NULL) return ret; @@@ -219,7 -218,7 +219,7 @@@ p = t; t = strchr(t, '>') + 1; ret->author_email = substr(p, t); - ret->author_date = atol(++t); + ret->author_date = atol(t+1); p = strchr(t, '\n') + 1; } @@@ -230,18 -229,10 +230,18 @@@ p = t; t = strchr(t, '>') + 1; ret->committer_email = substr(p, t); - ret->committer_date = atol(++t); + ret->committer_date = atol(t+1); p = strchr(t, '\n') + 1; } + if (!strncmp(p, "encoding ", 9)) { + p += 9; + t = strchr(p, '\n') + 1; + ret->msg_encoding = substr(p, t); + p = t; + } else + ret->msg_encoding = xstrdup(PAGE_ENCODING); + while (*p && (*p != '\n')) p = strchr(p, '\n') + 1; // skip unknown header fields @@@ -262,22 -253,6 +262,22 @@@ } else ret->subject = substr(p, p+strlen(p)); + if(strcmp(ret->msg_encoding, PAGE_ENCODING)) { + t = reencode_string(ret->subject, PAGE_ENCODING, + ret->msg_encoding); + if(t) { + free(ret->subject); + ret->subject = t; + } + + t = reencode_string(ret->msg, PAGE_ENCODING, + ret->msg_encoding); + if(t) { + free(ret->msg); + ret->msg = t; + } + } + return ret; } @@@ -315,7 -290,7 +315,7 @@@ struct taginfo *cgit_parse_tag(struct t p = t; t = strchr(t, '>') + 1; ret->tagger_email = substr(p, t); - ret->tagger_date = atol(++t); + ret->tagger_date = atol(t+1); } p = strchr(p, '\n') + 1; } diff --combined ui-shared.c index be2c75d,4944dfd2..3e13c86 --- a/ui-shared.c +++ b/ui-shared.c @@@ -304,6 -304,8 +304,8 @@@ void cgit_print_date(time_t secs, char char buf[64]; struct tm *time; + if (!secs) + return; time = gmtime(&secs); strftime(buf, sizeof(buf)-1, format, time); html_txt(buf); @@@ -313,6 -315,8 +315,8 @@@ void cgit_print_age(time_t t, time_t ma { time_t now, secs; + if (!t) + return; time(&now); secs = now - t; @@@ -352,20 -356,18 +356,20 @@@ void cgit_print_docstart(char *title, struct cacheitem *item) { - html("Content-Type: text/html; charset=utf-8\n"); + html("Content-Type: text/html; charset=" PAGE_ENCODING "\n"); htmlf("Last-Modified: %s\n", http_date(item->st.st_mtime)); htmlf("Expires: %s\n", http_date(item->st.st_mtime + ttl_seconds(item->ttl))); html("\n"); html(cgit_doctype); - html("\n"); + html("\n"); html("\n"); html(""); html_txt(title); html("\n"); htmlf("\n", cgit_version); + if (cgit_robots && *cgit_robots) + htmlf("\n", cgit_robots); html("\n"); @@@ -375,7 -377,7 +379,7 @@@ void cgit_print_docend() { - html("\n\n\n\n\n"); + html("\n\n
\n\n\n"); } int print_branch_option(const char *refname, const unsigned char *sha1, @@@ -413,7 -415,7 +417,7 @@@ int print_archive_ref(const char *refna hashcpy(fileid, sha1); } if (!*header) { - html("

download

"); + html("

download

\n"); *header = 1; } url = cgit_pageurl(cgit_query_repo, "blob", @@@ -457,24 -459,22 +461,24 @@@ void cgit_print_pageheader(char *title static const char *default_info = "This is cgit, a fast webinterface for git repositories"; int header = 0; - html("