History

ui-log: Add "commit-sort" option for controlling commit ordering

This makes it possible to use strict commit date ordering or strict topological ordering by passing the corresponding flags to "git log".

Tobias Bieniek committed 14 years ago

Commit 792f8131 parent 7a4e7c88 files · +40 −6Browse files

Unified · Split

8 files
  1. cgit.c +12 −2
  2. cgit.h +2 −0
  3. cgitrc.5.txt +12 −0
  4. cmd.c +2 −1
  5. shared.c +1 −0
  6. ui-log.c +9 −1
  7. ui-log.h +1 −1
  8. ui-summary.c +1 −1
cgit.c+12−2
@@ -84,7 +84,12 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) · 83 unmodified lines
8484 repo->enable_remote_branches = atoi(value);
8585 else if (!strcmp(name, "enable-subject-links"))
8686 repo->enable_subject_links = atoi(value);
87− else if (!strcmp(name, "max-stats"))
87+ else if (!strcmp(name, "commit-sort")) {
88+ if (!strcmp(value, "date"))
89+ repo->commit_sort = 1;
90+ if (!strcmp(value, "topo"))
91+ repo->commit_sort = 2;
92+ } else if (!strcmp(name, "max-stats"))
8893 repo->max_stats = cgit_find_stats_period(value, NULL);
8994 else if (!strcmp(name, "module-link"))
9095 repo->module_link= xstrdup(value);
@@ -261,7 +266,12 @@ void config_cb(const char *name, const char *value) · 170 unmodified lines
261266 ctx.cfg.clone_url = xstrdup(value);
262267 else if (!strcmp(name, "local-time"))
263268 ctx.cfg.local_time = atoi(value);
264− else if (!prefixcmp(name, "mimetype."))
269+ else if (!strcmp(name, "commit-sort")) {
270+ if (!strcmp(value, "date"))
271+ ctx.cfg.commit_sort = 1;
272+ if (!strcmp(value, "topo"))
273+ ctx.cfg.commit_sort = 2;
274+ } else if (!prefixcmp(name, "mimetype."))
265275 add_mimetype(name + 9, value);
266276 else if (!strcmp(name, "include"))
267277 parse_configfile(expand_macros(value), config_cb);
cgit.h+2−0
@@ -84,6 +84,7 @@ struct cgit_repo { · 83 unmodified lines
8484 int enable_remote_branches;
8585 int enable_subject_links;
8686 int max_stats;
87+ int commit_sort;
8788 time_t mtime;
8889 struct cgit_filter *about_filter;
8990 struct cgit_filter *commit_filter;
@@ -231,6 +232,7 @@ struct cgit_config { · 141 unmodified lines
231232 int summary_log;
232233 int summary_tags;
233234 int ssdiff;
235+ int commit_sort;
234236 struct string_list mimetypes;
235237 struct cgit_filter *about_filter;
236238 struct cgit_filter *commit_filter;
cgitrc.5.txt+12−0
@@ -192,6 +192,12 @@ local-time:: · 191 unmodified lines
192192 Flag which, if set to "1", makes cgit print commit and tag times in the
193193 servers timezone. Default value: "0".
194194
195+commit-sort::
196+ Flag which, when set to "date", enables strict date ordering in the
197+ commit log, and when set to "topo" enables strict topological
198+ ordering. If unset, the default ordering of "git log" is used. Default
199+ value: unset.
200+
195201 logo::
196202 Url which specifies the source of an image which will be used as a logo
197203 on all cgit pages. Default value: "/cgit.png".
@@ -435,6 +441,12 @@ repo.enable-subject-links:: · 237 unmodified lines
435441 A flag which can be used to override the global setting
436442 `enable-subject-links'. Default value: none.
437443
444+repo.commit-sort::
445+ Flag which, when set to "date", enables strict date ordering in the
446+ commit log, and when set to "topo" enables strict topological
447+ ordering. If unset, the default ordering of "git log" is used. Default
448+ value: unset.
449+
438450 repo.logo::
439451 Url which specifies the source of an image which will be used as a logo
440452 on this repo's pages. Default value: global logo.
cmd.c+2−1
@@ -68,7 +68,8 @@ static void log_fn(struct cgit_context *ctx) · 67 unmodified lines
6868 {
6969 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
7070 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1,
71− ctx->repo->enable_commit_graph);
71+ ctx->repo->enable_commit_graph,
72+ ctx->repo->commit_sort);
7273 }
7374
7475 static void ls_cache_fn(struct cgit_context *ctx)
shared.c+1−0
@@ -63,6 +63,7 @@ struct cgit_repo *cgit_add_repo(const char *url) · 62 unmodified lines
6363 ret->enable_remote_branches = ctx.cfg.enable_remote_branches;
6464 ret->enable_subject_links = ctx.cfg.enable_subject_links;
6565 ret->max_stats = ctx.cfg.max_stats;
66+ ret->commit_sort = ctx.cfg.commit_sort;
6667 ret->module_link = ctx.cfg.module_link;
6768 ret->readme = ctx.cfg.readme;
6869 ret->mtime = -1;
ui-log.c+9−1
@@ -278,7 +278,7 @@ static char *next_token(char **src) · 277 unmodified lines
278278 }
279279
280280 void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,
281− char *path, int pager, int commit_graph)
281+ char *path, int pager, int commit_graph, int commit_sort)
282282 {
283283 struct rev_info rev;
284284 struct commit *commit;
@@ -327,6 +327,14 @@ void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern · 42 unmodified lines
327327 COLUMN_COLORS_HTML_MAX);
328328 }
329329
330+ if (commit_sort == 1) {
331+ static const char *date_order_arg = "--date-order";
332+ vector_push(&vec, &date_order_arg, 0);
333+ } else if (commit_sort == 2) {
334+ static const char *topo_order_arg = "--topo-order";
335+ vector_push(&vec, &topo_order_arg, 0);
336+ }
337+
330338 if (path) {
331339 arg = "--";
332340 vector_push(&vec, &arg, 0);
ui-log.h+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
33
44 extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
55 char *pattern, char *path, int pager,
6− int commit_graph);
6+ int commit_graph, int commit_sort);
77 extern void show_commit_decorations(struct commit *commit);
88
99 #endif /* UI_LOG_H */
ui-summary.c+1−1
@@ -59,7 +59,7 @@ void cgit_print_summary() · 58 unmodified lines
5959 if (ctx.cfg.summary_log > 0) {
6060 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
6161 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
62− NULL, NULL, 0, 0);
62+ NULL, NULL, 0, 0, 0);
6363 }
6464 if (ctx.repo->clone_url)
6565 print_urls(expand_macros(ctx.repo->clone_url), NULL);