From 57ea1aa2a5eab7f6aba702b3366fe4dcc72124f6 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:01 +0000 Subject: ui-shared: remove "format" from cgit_print_age() We never use any format other than FMT_SHORTDATE, so move that into the function. Signed-off-by: John Keeping --- ui-log.c | 4 ++-- ui-refs.c | 6 +++--- ui-repolist.c | 2 +- ui-shared.c | 4 ++-- ui-shared.h | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ui-log.c b/ui-log.c index a4dc707..5f6a69c 100644 --- a/ui-log.c +++ b/ui-log.c @@ -204,7 +204,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) } else { html(""); - cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); + cgit_print_age(commit->date, TM_WEEK * 2); html(""); } @@ -244,7 +244,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) if (revs->graph) { html(""); - cgit_print_age(commit->date, TM_WEEK * 2, FMT_SHORTDATE); + cgit_print_age(commit->date, TM_WEEK * 2); } if (!lines_counted && (ctx.repo->enable_log_filecount || diff --git a/ui-refs.c b/ui-refs.c index 295a4c7..0652b89 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -73,7 +73,7 @@ static int print_branch(struct refinfo *ref) html_txt(info->author); cgit_close_filter(ctx.repo->email_filter); html(""); - cgit_print_age(info->commit->date, -1, NULL); + cgit_print_age(info->commit->date, -1); } else { html(""); cgit_object_link(ref->object); @@ -161,9 +161,9 @@ static int print_tag(struct refinfo *ref) html(""); if (info) { if (info->tagger_date > 0) - cgit_print_age(info->tagger_date, -1, NULL); + cgit_print_age(info->tagger_date, -1); } else if (ref->object->type == OBJ_COMMIT) { - cgit_print_age(ref->commit->commit->date, -1, NULL); + cgit_print_age(ref->commit->commit->date, -1); } html("\n"); diff --git a/ui-repolist.c b/ui-repolist.c index 6010a39..6004469 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -79,7 +79,7 @@ static void print_modtime(struct cgit_repo *repo) { time_t t; if (get_repo_modtime(repo, &t)) - cgit_print_age(t, -1, NULL); + cgit_print_age(t, -1); } static int is_match(struct cgit_repo *repo) diff --git a/ui-shared.c b/ui-shared.c index 54bbde7..76aac60 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -635,7 +635,7 @@ static void print_rel_date(time_t t, double value, htmlf("'>%.0f %s", value, suffix); } -void cgit_print_age(time_t t, time_t max_relative, const char *format) +void cgit_print_age(time_t t, time_t max_relative) { time_t now, secs; @@ -650,7 +650,7 @@ void cgit_print_age(time_t t, time_t max_relative, const char *format) html(""); - cgit_print_date(t, format, ctx.cfg.local_time); + cgit_print_date(t, FMT_SHORTDATE, ctx.cfg.local_time); html(""); return; } diff --git a/ui-shared.h b/ui-shared.h index de08e1b..c9413ed 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -62,7 +62,7 @@ extern void cgit_print_error(const char *fmt, ...); __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); extern void cgit_print_date(time_t secs, const char *format, int local_time); -extern void cgit_print_age(time_t t, time_t max_relative, const char *format); +extern void cgit_print_age(time_t t, time_t max_relative); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); extern void cgit_print_docstart(void); -- cgit v1.1 From 45c87ca1c32dcd5ffd4a681fadf05627d9ce7770 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:02 +0000 Subject: parsing: add timezone to ident structures This will allow us to mimic Git's behaviour of showing times in the originator's timezone when displaying commits and tags. Signed-off-by: John Keeping --- cgit.h | 3 +++ parsing.c | 10 ++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cgit.h b/cgit.h index de5c94a..501cb48 100644 --- a/cgit.h +++ b/cgit.h @@ -130,9 +130,11 @@ struct commitinfo { char *author; char *author_email; unsigned long author_date; + int author_tz; char *committer; char *committer_email; unsigned long committer_date; + int committer_tz; char *subject; char *msg; char *msg_encoding; @@ -142,6 +144,7 @@ struct taginfo { char *tagger; char *tagger_email; unsigned long tagger_date; + int tagger_tz; char *msg; }; diff --git a/parsing.c b/parsing.c index 5283e58..9dacb16 100644 --- a/parsing.c +++ b/parsing.c @@ -69,7 +69,7 @@ static char *substr(const char *head, const char *tail) return buf; } -static void parse_user(const char *t, char **name, char **email, unsigned long *date) +static void parse_user(const char *t, char **name, char **email, unsigned long *date, int *tz) { struct ident_split ident; unsigned email_len; @@ -83,6 +83,8 @@ static void parse_user(const char *t, char **name, char **email, unsigned long * if (ident.date_begin) *date = strtoul(ident.date_begin, NULL, 10); + if (ident.tz_begin) + *tz = atoi(ident.tz_begin); } } @@ -147,13 +149,13 @@ struct commitinfo *cgit_parse_commit(struct commit *commit) if (p && skip_prefix(p, "author ", &p)) { parse_user(p, &ret->author, &ret->author_email, - &ret->author_date); + &ret->author_date, &ret->author_tz); p = next_header_line(p); } if (p && skip_prefix(p, "committer ", &p)) { parse_user(p, &ret->committer, &ret->committer_email, - &ret->committer_date); + &ret->committer_date, &ret->committer_tz); p = next_header_line(p); } @@ -208,7 +210,7 @@ struct taginfo *cgit_parse_tag(struct tag *tag) for (p = data; !end_of_header(p); p = next_header_line(p)) { if (skip_prefix(p, "tagger ", &p)) { parse_user(p, &ret->tagger, &ret->tagger_email, - &ret->tagger_date); + &ret->tagger_date, &ret->tagger_tz); } } -- cgit v1.1 From 360af46fac6fe79ec1868141a6c34b4c6b732ba0 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:03 +0000 Subject: ui-shared: add cgit_date_mode() This returns the correct mode value for use with Git's show_date() based on the current CGit configuration and will be used in the following patches. Signed-off-by: John Keeping --- ui-shared.c | 9 +++++++++ ui-shared.h | 1 + 2 files changed, 10 insertions(+) diff --git a/ui-shared.c b/ui-shared.c index 76aac60..923d102 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -627,6 +627,15 @@ void cgit_print_date(time_t secs, const char *format, int local_time) html_txt(fmt_date(secs, format, local_time)); } +const struct date_mode *cgit_date_mode(const char *format) +{ + static struct date_mode mode; + mode.type = DATE_STRFTIME; + mode.strftime_fmt = format; + mode.local = ctx.cfg.local_time; + return &mode; +} + static void print_rel_date(time_t t, double value, const char *class, const char *suffix) { diff --git a/ui-shared.h b/ui-shared.h index c9413ed..707cec9 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -61,6 +61,7 @@ __attribute__((format (printf,1,2))) extern void cgit_print_error(const char *fmt, ...); __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); +extern const struct date_mode *cgit_date_mode(const char *format); extern void cgit_print_date(time_t secs, const char *format, int local_time); extern void cgit_print_age(time_t t, time_t max_relative); extern void cgit_print_http_headers(void); -- cgit v1.1 From 21dcf10386551a2eee3e552c3213bb14e535cbba Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:04 +0000 Subject: ui-{commit,tag}: show dates in originator's timezone This is done by switching to Git's show_date() function and the mode given by cgit_date_mode(). Signed-off-by: John Keeping --- ui-commit.c | 6 ++++-- ui-tag.c | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ui-commit.c b/ui-commit.c index 0c3d740..e697571 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -55,7 +55,8 @@ void cgit_print_commit(char *hex, const char *prefix) } cgit_close_filter(ctx.repo->email_filter); html(""); - cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time); + html_txt(show_date(info->author_date, info->author_tz, + cgit_date_mode(FMT_LONGDATE))); html("\n"); html("committer"); cgit_open_filter(ctx.repo->email_filter, info->committer_email, "commit"); @@ -66,7 +67,8 @@ void cgit_print_commit(char *hex, const char *prefix) } cgit_close_filter(ctx.repo->email_filter); html(""); - cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time); + html_txt(show_date(info->committer_date, info->committer_tz, + cgit_date_mode(FMT_LONGDATE))); html("\n"); html("commit"); tmp = oid_to_hex(&commit->object.oid); diff --git a/ui-tag.c b/ui-tag.c index 0afc663..b011198 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -76,7 +76,8 @@ void cgit_print_tag(char *revname) htmlf(" (%s)\n", sha1_to_hex(sha1)); if (info->tagger_date > 0) { html("tag date"); - cgit_print_date(info->tagger_date, FMT_LONGDATE, ctx.cfg.local_time); + html_txt(show_date(info->tagger_date, info->tagger_tz, + cgit_date_mode(FMT_LONGDATE))); html("\n"); } if (info->tagger) { -- cgit v1.1 From f2a901d2e1db5217d6890b26c6dc1ec119505d02 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:05 +0000 Subject: ui: show ages in the originator's timezone This affects the tooltip showing the full time and the case when a date is sufficiently old to be shown in full rather than as an offset. Signed-off-by: John Keeping --- ui-log.c | 4 ++-- ui-refs.c | 6 +++--- ui-repolist.c | 2 +- ui-shared.c | 22 +++++++++++----------- ui-shared.h | 2 +- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ui-log.c b/ui-log.c index 5f6a69c..0a3938b 100644 --- a/ui-log.c +++ b/ui-log.c @@ -204,7 +204,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) } else { html(""); - cgit_print_age(commit->date, TM_WEEK * 2); + cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); html(""); } @@ -244,7 +244,7 @@ static void print_commit(struct commit *commit, struct rev_info *revs) if (revs->graph) { html(""); - cgit_print_age(commit->date, TM_WEEK * 2); + cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); } if (!lines_counted && (ctx.repo->enable_log_filecount || diff --git a/ui-refs.c b/ui-refs.c index 0652b89..5b4530e 100644 --- a/ui-refs.c +++ b/ui-refs.c @@ -73,7 +73,7 @@ static int print_branch(struct refinfo *ref) html_txt(info->author); cgit_close_filter(ctx.repo->email_filter); html(""); - cgit_print_age(info->commit->date, -1); + cgit_print_age(info->committer_date, info->committer_tz, -1); } else { html(""); cgit_object_link(ref->object); @@ -161,9 +161,9 @@ static int print_tag(struct refinfo *ref) html(""); if (info) { if (info->tagger_date > 0) - cgit_print_age(info->tagger_date, -1); + cgit_print_age(info->tagger_date, info->tagger_tz, -1); } else if (ref->object->type == OBJ_COMMIT) { - cgit_print_age(ref->commit->commit->date, -1); + cgit_print_age(ref->commit->commit->date, 0, -1); } html("\n"); diff --git a/ui-repolist.c b/ui-repolist.c index 6004469..30915df 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -79,7 +79,7 @@ static void print_modtime(struct cgit_repo *repo) { time_t t; if (get_repo_modtime(repo, &t)) - cgit_print_age(t, -1); + cgit_print_age(t, 0, -1); } static int is_match(struct cgit_repo *repo) diff --git a/ui-shared.c b/ui-shared.c index 923d102..3ce86fe 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -636,15 +636,15 @@ const struct date_mode *cgit_date_mode(const char *format) return &mode; } -static void print_rel_date(time_t t, double value, +static void print_rel_date(time_t t, int tz, double value, const char *class, const char *suffix) { htmlf("%.0f %s", value, suffix); } -void cgit_print_age(time_t t, time_t max_relative) +void cgit_print_age(time_t t, int tz, time_t max_relative) { time_t now, secs; @@ -657,34 +657,34 @@ void cgit_print_age(time_t t, time_t max_relative) if (secs > max_relative && max_relative >= 0) { html(""); - cgit_print_date(t, FMT_SHORTDATE, ctx.cfg.local_time); + html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE))); html(""); return; } if (secs < TM_HOUR * 2) { - print_rel_date(t, secs * 1.0 / TM_MIN, "age-mins", "min."); + print_rel_date(t, tz, secs * 1.0 / TM_MIN, "age-mins", "min."); return; } if (secs < TM_DAY * 2) { - print_rel_date(t, secs * 1.0 / TM_HOUR, "age-hours", "hours"); + print_rel_date(t, tz, secs * 1.0 / TM_HOUR, "age-hours", "hours"); return; } if (secs < TM_WEEK * 2) { - print_rel_date(t, secs * 1.0 / TM_DAY, "age-days", "days"); + print_rel_date(t, tz, secs * 1.0 / TM_DAY, "age-days", "days"); return; } if (secs < TM_MONTH * 2) { - print_rel_date(t, secs * 1.0 / TM_WEEK, "age-weeks", "weeks"); + print_rel_date(t, tz, secs * 1.0 / TM_WEEK, "age-weeks", "weeks"); return; } if (secs < TM_YEAR * 2) { - print_rel_date(t, secs * 1.0 / TM_MONTH, "age-months", "months"); + print_rel_date(t, tz, secs * 1.0 / TM_MONTH, "age-months", "months"); return; } - print_rel_date(t, secs * 1.0 / TM_YEAR, "age-years", "years"); + print_rel_date(t, tz, secs * 1.0 / TM_YEAR, "age-years", "years"); } void cgit_print_http_headers(void) diff --git a/ui-shared.h b/ui-shared.h index 707cec9..e42f13a 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -63,7 +63,7 @@ __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); extern const struct date_mode *cgit_date_mode(const char *format); extern void cgit_print_date(time_t secs, const char *format, int local_time); -extern void cgit_print_age(time_t t, time_t max_relative); +extern void cgit_print_age(time_t t, int tz, time_t max_relative); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); extern void cgit_print_docstart(void); -- cgit v1.1 From e68c86e8c54a6f03e7405dff3d38995c6c42e4fa Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:06 +0000 Subject: ui-shared: use show_date for footer timestamp Signed-off-by: John Keeping --- ui-shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-shared.c b/ui-shared.c index 3ce86fe..eaa45fb 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -801,7 +801,7 @@ void cgit_print_docend(void) else { htmlf("\n"); } html(" \n"); -- cgit v1.1 From eb80b4edadd07957f667f057c82875c30a822a1f Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:07 +0000 Subject: ui-atom: use show_date directly for atom dates This will allow us to remove cgit_print_date and use Git's show_date consistently. Signed-off-by: John Keeping --- ui-atom.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui-atom.c b/ui-atom.c index 11ea0c0..0bf2cf2 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -17,6 +17,11 @@ static void add_entry(struct commit *commit, const char *host) char *hex; char *mail, *t, *t2; struct commitinfo *info; + struct date_mode mode = { + .type = DATE_STRFTIME, + .strftime_fmt = FMT_ATOMDATE, + .local = 0, + }; info = cgit_parse_commit(commit); hex = oid_to_hex(&commit->object.oid); @@ -25,7 +30,7 @@ static void add_entry(struct commit *commit, const char *host) html_txt(info->subject); html("\n"); html(""); - cgit_print_date(info->committer_date, FMT_ATOMDATE, 0); + html_txt(show_date(info->committer_date, 0, &mode)); html("\n"); html("\n"); if (info->author) { @@ -50,7 +55,7 @@ static void add_entry(struct commit *commit, const char *host) } html("\n"); html(""); - cgit_print_date(info->author_date, FMT_ATOMDATE, 0); + html_txt(show_date(info->author_date, 0, &mode)); html("\n"); if (host) { char *pageurl; -- cgit v1.1 From 17c74eefa4390d42a244b12885dc63ac4a764e44 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Tue, 19 Jan 2016 19:33:08 +0000 Subject: ui-shared: remove cgit_print_date() There are no longer any users of this function. Signed-off-by: John Keeping --- ui-shared.c | 20 -------------------- ui-shared.h | 1 - 2 files changed, 21 deletions(-) diff --git a/ui-shared.c b/ui-shared.c index eaa45fb..d1f9249 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -607,26 +607,6 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) path[len - 1] = tail; } -static const char *fmt_date(time_t secs, const char *format, int local_time) -{ - static char buf[64]; - struct tm *time; - - if (!secs) - return ""; - if (local_time) - time = localtime(&secs); - else - time = gmtime(&secs); - strftime(buf, sizeof(buf)-1, format, time); - return buf; -} - -void cgit_print_date(time_t secs, const char *format, int local_time) -{ - html_txt(fmt_date(secs, format, local_time)); -} - const struct date_mode *cgit_date_mode(const char *format) { static struct date_mode mode; diff --git a/ui-shared.h b/ui-shared.h index e42f13a..43789de 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -62,7 +62,6 @@ extern void cgit_print_error(const char *fmt, ...); __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); extern const struct date_mode *cgit_date_mode(const char *format); -extern void cgit_print_date(time_t secs, const char *format, int local_time); extern void cgit_print_age(time_t t, int tz, time_t max_relative); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); -- cgit v1.1 From 85ec9f0211a0c83d6cca744e6e40d73daf4050fc Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 8 Feb 2016 09:06:47 +0100 Subject: git: update to v2.7.1 Update to git version v2.7.1, no changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6590d8e..8bd7a0e 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.7.0 +GIT_VER = 2.7.1 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index 7548842..a08595f 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit 754884255bb580df159e58defa81cdd30b5c430c +Subproject commit a08595f76159b09d57553e37a5123f1091bb13e7 -- cgit v1.1 From a8b9ef8c1c68fbb9c89db2d8c12dca38c15e2bfd Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 8 Feb 2016 14:35:47 +0100 Subject: ui-stats: if we're going to abuse void*, do it safely --- ui-stats.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/ui-stats.c b/ui-stats.c index 74ce0f7..a9c13fd 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -3,12 +3,6 @@ #include "html.h" #include "ui-shared.h" -#ifdef NO_C99_FORMAT -#define SZ_FMT "%u" -#else -#define SZ_FMT "%zu" -#endif - struct authorstat { long total; struct string_list list; @@ -174,6 +168,7 @@ static void add_commit(struct string_list *authors, struct commit *commit, char *tmp; struct tm *date; time_t t; + uintptr_t *counter; info = cgit_parse_commit(commit); tmp = xstrdup(info->author); @@ -191,7 +186,9 @@ static void add_commit(struct string_list *authors, struct commit *commit, item = string_list_insert(items, tmp); if (item->util) free(tmp); - item->util++; + counter = (uintptr_t *)&item->util; + (*counter)++; + authorstat->total++; cgit_free_commitinfo(info); } @@ -286,7 +283,7 @@ static void print_combined_authorrow(struct string_list *authors, int from, items = &authorstat->list; date = string_list_lookup(items, tmp); if (date) - subtotal += (size_t)date->util; + subtotal += (uintptr_t)date->util; } htmlf("%ld", centerclass, subtotal); total += subtotal; @@ -340,8 +337,8 @@ static void print_authors(struct string_list *authors, int top, if (!date) html("0"); else { - htmlf(""SZ_FMT"", (size_t)date->util); - total += (size_t)date->util; + htmlf("%lu", (uintptr_t)date->util); + total += (uintptr_t)date->util; } } htmlf("%ld", total); -- cgit v1.1 From bdcbe0922d7099ebd61d875709ea9408bc1d7543 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Mon, 8 Feb 2016 14:12:35 +0000 Subject: ui-stats: cast pointer before checking for zero We abuse the "void *util" field as a counter and recently started to cast it to a uintptr_t to avoid risking nasal demons by performing arithmetic on a void pointer. However, compilers are also known to do "interesting" things if they know that a pointer is or isn't NULL. Make this safer by checking if the counter (after casting) is non-zero rather than checking if the pointer is non-null. Signed-off-by: John Keeping --- ui-stats.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-stats.c b/ui-stats.c index a9c13fd..8cd9178 100644 --- a/ui-stats.c +++ b/ui-stats.c @@ -184,9 +184,9 @@ static void add_commit(struct string_list *authors, struct commit *commit, period->trunc(date); tmp = xstrdup(period->pretty(date)); item = string_list_insert(items, tmp); - if (item->util) - free(tmp); counter = (uintptr_t *)&item->util; + if (*counter) + free(tmp); (*counter)++; authorstat->total++; -- cgit v1.1 From 9c15f3c6954e43c5ffd36230e666eccf112803f2 Mon Sep 17 00:00:00 2001 From: John Keeping Date: Mon, 8 Feb 2016 15:05:54 +0000 Subject: Avoid DATE_STRFTIME for long/short dates Git's DATE_STRFTIME ignores the timezone argument and just uses the local timezone regardless of whether the "local" flag is set. Since our existing FMT_LONGDATE and FMT_SHORTDATE are pretty-much perfect matches to DATE_ISO8601 and DATE_SHORT, switch to taking a date_mode_type directly in cgit_date_mode(). Signed-off-by: John Keeping --- cgit.h | 2 -- ui-commit.c | 4 ++-- ui-shared.c | 13 ++++++------- ui-shared.h | 2 +- ui-tag.c | 2 +- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cgit.h b/cgit.h index 501cb48..5adef4d 100644 --- a/cgit.h +++ b/cgit.h @@ -32,8 +32,6 @@ /* * Dateformats used on misc. pages */ -#define FMT_LONGDATE "%Y-%m-%d %H:%M:%S (%Z)" -#define FMT_SHORTDATE "%Y-%m-%d" #define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" diff --git a/ui-commit.c b/ui-commit.c index e697571..099d294 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -56,7 +56,7 @@ void cgit_print_commit(char *hex, const char *prefix) cgit_close_filter(ctx.repo->email_filter); html(""); html_txt(show_date(info->author_date, info->author_tz, - cgit_date_mode(FMT_LONGDATE))); + cgit_date_mode(DATE_ISO8601))); html("\n"); html("committer"); cgit_open_filter(ctx.repo->email_filter, info->committer_email, "commit"); @@ -68,7 +68,7 @@ void cgit_print_commit(char *hex, const char *prefix) cgit_close_filter(ctx.repo->email_filter); html(""); html_txt(show_date(info->committer_date, info->committer_tz, - cgit_date_mode(FMT_LONGDATE))); + cgit_date_mode(DATE_ISO8601))); html("\n"); html("commit"); tmp = oid_to_hex(&commit->object.oid); diff --git a/ui-shared.c b/ui-shared.c index d1f9249..03dcc08 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -607,11 +607,10 @@ void cgit_submodule_link(const char *class, char *path, const char *rev) path[len - 1] = tail; } -const struct date_mode *cgit_date_mode(const char *format) +const struct date_mode *cgit_date_mode(enum date_mode_type type) { static struct date_mode mode; - mode.type = DATE_STRFTIME; - mode.strftime_fmt = format; + mode.type = type; mode.local = ctx.cfg.local_time; return &mode; } @@ -620,7 +619,7 @@ static void print_rel_date(time_t t, int tz, double value, const char *class, const char *suffix) { htmlf("%.0f %s", value, suffix); } @@ -637,9 +636,9 @@ void cgit_print_age(time_t t, int tz, time_t max_relative) if (secs > max_relative && max_relative >= 0) { html(""); - html_txt(show_date(t, tz, cgit_date_mode(FMT_SHORTDATE))); + html_txt(show_date(t, tz, cgit_date_mode(DATE_SHORT))); html(""); return; } @@ -781,7 +780,7 @@ void cgit_print_docend(void) else { htmlf("\n"); } html(" \n"); diff --git a/ui-shared.h b/ui-shared.h index 43789de..b457c97 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -61,7 +61,7 @@ __attribute__((format (printf,1,2))) extern void cgit_print_error(const char *fmt, ...); __attribute__((format (printf,1,0))) extern void cgit_vprint_error(const char *fmt, va_list ap); -extern const struct date_mode *cgit_date_mode(const char *format); +extern const struct date_mode *cgit_date_mode(enum date_mode_type type); extern void cgit_print_age(time_t t, int tz, time_t max_relative); extern void cgit_print_http_headers(void); extern void cgit_redirect(const char *url, bool permanent); diff --git a/ui-tag.c b/ui-tag.c index b011198..6b838cb 100644 --- a/ui-tag.c +++ b/ui-tag.c @@ -77,7 +77,7 @@ void cgit_print_tag(char *revname) if (info->tagger_date > 0) { html("tag date"); html_txt(show_date(info->tagger_date, info->tagger_tz, - cgit_date_mode(FMT_LONGDATE))); + cgit_date_mode(DATE_ISO8601))); html("\n"); } if (info->tagger) { -- cgit v1.1 From 75298209bf8386656b82f185e2901690ac5b671c Mon Sep 17 00:00:00 2001 From: John Keeping Date: Mon, 8 Feb 2016 15:06:27 +0000 Subject: ui-atom: avoid DATE_STRFTIME Git's DATE_STRFTIME ignores the timezone argument and just uses the local timezone regardless of whether the "local" flag is set. Since Atom accepts ISO8601 dates [1], we can use Git's DATE_ISO8601_STRICT instead, which does get this right. Additionally, we never use the local timezone here so we can use the date_mode_from_type() wrapper to simplify the code a bit. [1] https://tools.ietf.org/html/rfc4287#section-3.3 Signed-off-by: John Keeping --- cgit.h | 5 ----- ui-atom.c | 11 ++++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/cgit.h b/cgit.h index 5adef4d..d10c799 100644 --- a/cgit.h +++ b/cgit.h @@ -29,11 +29,6 @@ #undef isgraph #define isgraph(x) (isprint((x)) && !isspace((x))) -/* - * Dateformats used on misc. pages - */ -#define FMT_ATOMDATE "%Y-%m-%dT%H:%M:%SZ" - /* * Limits used for relative dates diff --git a/ui-atom.c b/ui-atom.c index 0bf2cf2..41838d3 100644 --- a/ui-atom.c +++ b/ui-atom.c @@ -17,11 +17,6 @@ static void add_entry(struct commit *commit, const char *host) char *hex; char *mail, *t, *t2; struct commitinfo *info; - struct date_mode mode = { - .type = DATE_STRFTIME, - .strftime_fmt = FMT_ATOMDATE, - .local = 0, - }; info = cgit_parse_commit(commit); hex = oid_to_hex(&commit->object.oid); @@ -30,7 +25,8 @@ static void add_entry(struct commit *commit, const char *host) html_txt(info->subject); html("\n"); html(""); - html_txt(show_date(info->committer_date, 0, &mode)); + html_txt(show_date(info->committer_date, 0, + date_mode_from_type(DATE_ISO8601_STRICT))); html("\n"); html("\n"); if (info->author) { @@ -55,7 +51,8 @@ static void add_entry(struct commit *commit, const char *host) } html("\n"); html(""); - html_txt(show_date(info->author_date, 0, &mode)); + html_txt(show_date(info->author_date, 0, + date_mode_from_type(DATE_ISO8601_STRICT))); html("\n"); if (host) { char *pageurl; -- cgit v1.1 From 5f2664f13c90f083b827d8fafa6cfc01c0c4f513 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 22 Feb 2016 16:04:15 +0100 Subject: ui-shared: add homepage to tabs Signed-off-by: Jason A. Donenfeld --- cgit.c | 4 ++++ cgit.css | 5 +++++ cgit.h | 1 + cgitrc.5.txt | 13 ++++++++----- scan-tree.c | 2 ++ shared.c | 1 + ui-shared.c | 5 +++++ 7 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cgit.c b/cgit.c index 7f83a2d..fc482be 100644 --- a/cgit.c +++ b/cgit.c @@ -41,6 +41,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->desc = xstrdup(value); else if (!strcmp(name, "owner")) repo->owner = xstrdup(value); + else if (!strcmp(name, "homepage")) + repo->homepage = xstrdup(value); else if (!strcmp(name, "defbranch")) repo->defbranch = xstrdup(value); else if (!strcmp(name, "snapshots")) @@ -793,6 +795,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo) fprintf(f, "repo.module-link=%s\n", repo->module_link); if (repo->section) fprintf(f, "repo.section=%s\n", repo->section); + if (repo->homepage) + fprintf(f, "repo.homepage=%s\n", repo->homepage); if (repo->clone_url) fprintf(f, "repo.clone-url=%s\n", repo->clone_url); fprintf(f, "repo.enable-commit-graph=%d\n", diff --git a/cgit.css b/cgit.css index 82c755c..50f6587 100644 --- a/cgit.css +++ b/cgit.css @@ -85,6 +85,11 @@ div#cgit table.tabs td a.active { background-color: #ccc; } +div#cgit table.tabs a[href^="http://"]:after, div#cgit table.tabs a[href^="https://"]:after { + content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAAnNCSVQICFXsRgQAAAAJcEhZcwAAABQAAAAUAVyMgXwAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAeklEQVQI12NoYCu3q3ABwXL98vTy/0D4jaF8XXldRRoYejAwlu8BCTOU72SAg4q08j/le0GC22BC5anlfyrSGBiBGCZYllz+pywLJg8WLOMtf1GeCjRgI5IgSBhMboUIHq40r1CCQrfyDRAV6uXdZTMhsKKlVIIBFwAAVeg4KFYK95cAAAAASUVORK5CYII=); + margin: 0 0 0 5px; +} + div#cgit table.tabs td.form { text-align: right; } diff --git a/cgit.h b/cgit.h index d10c799..325432b 100644 --- a/cgit.h +++ b/cgit.h @@ -81,6 +81,7 @@ struct cgit_repo { char *path; char *desc; char *owner; + char *homepage; char *defbranch; char *module_link; struct string_list readme; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 47850a8..94901bd 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -205,11 +205,11 @@ enable-git-config:: Flag which, when set to "1", will allow cgit to use git config to set any repo specific settings. This option is used in conjunction with "scan-path", and must be defined prior, to augment repo-specific - settings. The keys gitweb.owner, gitweb.category, and gitweb.description - will map to the cgit keys repo.owner, repo.section, and repo.desc, - respectively. All git config keys that begin with "cgit." will be mapped - to the corresponding "repo." key in cgit. Default value: "0". See also: - scan-path, section-from-path. + settings. The keys gitweb.owner, gitweb.category, gitweb.description, + and gitweb.homepage will map to the cgit keys repo.owner, repo.section, + repo.desc, and repo.homepage respectively. All git config keys that begin + with "cgit." will be mapped to the corresponding "repo." key in cgit. + Default value: "0". See also: scan-path, section-from-path. favicon:: Url used as link to a shortcut icon for cgit. It is suggested to use @@ -496,6 +496,9 @@ repo.defbranch:: repo.desc:: The value to show as repository description. Default value: none. +repo.homepage:: + The value to show as repository homepage. Default value: none. + repo.email-filter:: Override the default email-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". diff --git a/scan-tree.c b/scan-tree.c index b5a10ff..2e87999 100644 --- a/scan-tree.c +++ b/scan-tree.c @@ -61,6 +61,8 @@ static int gitconfig_config(const char *key, const char *value, void *cb) config_fn(repo, "desc", value); else if (!strcmp(key, "gitweb.category")) config_fn(repo, "section", value); + else if (!strcmp(key, "gitweb.homepage")) + config_fn(repo, "homepage", value); else if (starts_with(key, "cgit.")) config_fn(repo, key + 5, value); diff --git a/shared.c b/shared.c index a078a27..a63633b 100644 --- a/shared.c +++ b/shared.c @@ -54,6 +54,7 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->path = NULL; ret->desc = cgit_default_repo_desc; ret->owner = NULL; + ret->homepage = NULL; ret->section = ctx.cfg.section; ret->snapshots = ctx.cfg.snapshots; ret->enable_commit_graph = ctx.cfg.enable_commit_graph; diff --git a/ui-shared.c b/ui-shared.c index 03dcc08..2c91e75 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -997,6 +997,11 @@ void cgit_print_pageheader(void) if (ctx.repo->max_stats) cgit_stats_link("stats", NULL, hc("stats"), ctx.qry.head, ctx.qry.vpath); + if (ctx.repo->homepage) { + html("homepage"); + } html(""); html("
Signed-off-by: Jason A. Donenfeld --- ui-plain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-plain.c b/ui-plain.c index ff85113..97cf639 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -143,7 +143,7 @@ static int walk_tree(const unsigned char *sha1, struct strbuf *base, walk_tree_ctx->match = 2; return READ_TREE_RECURSIVE; } - } else if (base->len > walk_tree_ctx->match_baselen) { + } else if (base->len < INT_MAX && (int)base->len > walk_tree_ctx->match_baselen) { print_dir_entry(sha1, base->buf, base->len, pathname, mode); walk_tree_ctx->match = 2; } else if (S_ISDIR(mode)) { -- cgit v1.1 From a9e9dfc55f5c57a4065be77c320224f524a9c820 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 22 Feb 2016 23:25:28 +0100 Subject: git: update to v2.7.2 Update to git version v2.7.2, no changes required. Signed-off-by: Christian Hesse --- Makefile | 2 +- git | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8bd7a0e..c01701c 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ htmldir = $(docdir) pdfdir = $(docdir) mandir = $(prefix)/share/man SHA1_HEADER = -GIT_VER = 2.7.1 +GIT_VER = 2.7.2 GIT_URL = https://www.kernel.org/pub/software/scm/git/git-$(GIT_VER).tar.gz INSTALL = install COPYTREE = cp -r diff --git a/git b/git index a08595f..326e5bc 160000 --- a/git +++ b/git @@ -1 +1 @@ -Subproject commit a08595f76159b09d57553e37a5123f1091bb13e7 +Subproject commit 326e5bc91eecf73234ead29636207bc516573e79 -- cgit v1.1 From 1892cd9a603e1eda206c40efb576bd75b7532be6 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 23 Feb 2016 06:32:03 +0100 Subject: md2html: Do syntax highlighting too --- filters/html-converters/md2html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filters/html-converters/md2html b/filters/html-converters/md2html index 67141ba..c8ee7d9 100755 --- a/filters/html-converters/md2html +++ b/filters/html-converters/md2html @@ -1,5 +1,6 @@ #!/usr/bin/env python import markdown +from pygments.formatters import HtmlFormatter print(''' ''') print("
") # Note: you may want to run this through bleach for sanitization -markdown.markdownFromFile(output_format="html5") +markdown.markdownFromFile(output_format="html5", extensions=["markdown.extensions.fenced_code", "markdown.extensions.codehilite", "markdown.extensions.tables"], extension_configs={"markdown.extensions.codehilite":{"css_class":"highlight"}}) print("
") -- cgit v1.1 From a0d22c391e6e2bbe0d10a888df1ba77a468d5a18 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 23 Feb 2016 10:47:25 +0100 Subject: css: use less blurry icon for external link Your mileage may vary, but for me the old icon looks blurry. The new one is character 0xf08e from OTF font awsome in size 10. The icon color is black, gray level is adjusted via opacity. Signed-off-by: Christian Hesse --- cgit.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cgit.css b/cgit.css index 50f6587..942c9be 100644 --- a/cgit.css +++ b/cgit.css @@ -86,7 +86,8 @@ div#cgit table.tabs td a.active { } div#cgit table.tabs a[href^="http://"]:after, div#cgit table.tabs a[href^="https://"]:after { - content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAAnNCSVQICFXsRgQAAAAJcEhZcwAAABQAAAAUAVyMgXwAAAAZdEVYdFNvZnR3YXJlAHd3dy5pbmtzY2FwZS5vcmeb7jwaAAAAeklEQVQI12NoYCu3q3ABwXL98vTy/0D4jaF8XXldRRoYejAwlu8BCTOU72SAg4q08j/le0GC22BC5anlfyrSGBiBGCZYllz+pywLJg8WLOMtf1GeCjRgI5IgSBhMboUIHq40r1CCQrfyDRAV6uXdZTMhsKKlVIIBFwAAVeg4KFYK95cAAAAASUVORK5CYII=); + content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAQAAAAnOwc2AAAAAmJLR0QA/4ePzL8AAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfgAhcJDQY+gm2TAAAAHWlUWHRDb21tZW50AAAAAABDcmVhdGVkIHdpdGggR0lNUGQuZQcAAABbSURBVAhbY2BABs4MU4CwhYHBh2Erww4wrGFQZHjI8B8IgUIscJWyDHcggltQhI4zGDCcRwhChPggHIggP1QoAVmQkSETrGoHsiAEsACtBYN0oDAMbgU6EBcAAL2eHUt4XUU4AAAAAElFTkSuQmCC); + opacity: 0.5; margin: 0 0 0 5px; } -- cgit v1.1 From 46ff6e1993175057a18b14980696648a1c5e87ab Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 23 Feb 2016 15:14:06 +0100 Subject: css: fix indentation --- cgit.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cgit.css b/cgit.css index 942c9be..66c6d53 100644 --- a/cgit.css +++ b/cgit.css @@ -18,7 +18,7 @@ div#cgit a:hover { } div#cgit table { - border-collapse: collapse; + border-collapse: collapse; } div#cgit table#header { @@ -803,9 +803,9 @@ div#cgit table.ssdiff td.head div.head { div#cgit table.ssdiff td.foot { border-top: solid 1px #aaa; - border-left: none; - border-right: none; - border-bottom: none; + border-left: none; + border-right: none; + border-bottom: none; } div#cgit table.ssdiff td.space { -- cgit v1.1 From c424b5cb0253d8b55d3932efa51aa703dab2bf40 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Tue, 23 Feb 2016 15:35:32 +0100 Subject: tabs: do not use target=_blank --- ui-shared.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-shared.c b/ui-shared.c index 2c91e75..3b2dc06 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1000,7 +1000,7 @@ void cgit_print_pageheader(void) if (ctx.repo->homepage) { html("homepage"); + html("'>homepage"); } html(""); html(" Date: Fri, 26 Feb 2016 13:24:35 +0100 Subject: ui-shared: redirect should not exit early for cache Signed-off-by: Jason A. Donenfeld --- ui-shared.c | 1 - 1 file changed, 1 deletion(-) diff --git a/ui-shared.c b/ui-shared.c index 3b2dc06..9a38aa9 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -702,7 +702,6 @@ void cgit_redirect(const char *url, bool permanent) html("Location: "); html_url_path(url); html("\n\n"); - exit(0); } static void print_rel_vcs_link(const char *url) -- cgit v1.1 From 39735d95ca8775204ed4c5f306009707f7da79c6 Mon Sep 17 00:00:00 2001 From: Matt Comben Date: Tue, 8 Mar 2016 12:05:09 +0000 Subject: Renamed repo-specific configuration for enable-html-serving in cgitrc.5.txt --- cgitrc.5.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 94901bd..2e1912d 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -523,7 +523,7 @@ repo.enable-subject-links:: A flag which can be used to override the global setting `enable-subject-links'. Default value: none. -enable-html-serving:: +repo.enable-html-serving:: A flag which can be used to override the global setting `enable-html-serving`. Default value: none. -- cgit v1.1