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
84 repo->enable_remote_branches = atoi(value);84 repo->enable_remote_branches = atoi(value);
85 else if (!strcmp(name, "enable-subject-links"))85 else if (!strcmp(name, "enable-subject-links"))
86 repo->enable_subject_links = atoi(value);86 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"))
88 repo->max_stats = cgit_find_stats_period(value, NULL);93 repo->max_stats = cgit_find_stats_period(value, NULL);
89 else if (!strcmp(name, "module-link"))94 else if (!strcmp(name, "module-link"))
90 repo->module_link= xstrdup(value);95 repo->module_link= xstrdup(value);
@@ -261,7 +266,12 @@ void config_cb(const char *name, const char *value) · 170 unmodified lines
261 ctx.cfg.clone_url = xstrdup(value);266 ctx.cfg.clone_url = xstrdup(value);
262 else if (!strcmp(name, "local-time"))267 else if (!strcmp(name, "local-time"))
263 ctx.cfg.local_time = atoi(value);268 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."))
265 add_mimetype(name + 9, value);275 add_mimetype(name + 9, value);
266 else if (!strcmp(name, "include"))276 else if (!strcmp(name, "include"))
267 parse_configfile(expand_macros(value), config_cb);277 parse_configfile(expand_macros(value), config_cb);
cgit.h+2−0
@@ -84,6 +84,7 @@ struct cgit_repo { · 83 unmodified lines
84 int enable_remote_branches;84 int enable_remote_branches;
85 int enable_subject_links;85 int enable_subject_links;
86 int max_stats;86 int max_stats;
87 int commit_sort;
87 time_t mtime;88 time_t mtime;
88 struct cgit_filter *about_filter;89 struct cgit_filter *about_filter;
89 struct cgit_filter *commit_filter;90 struct cgit_filter *commit_filter;
@@ -231,6 +232,7 @@ struct cgit_config { · 141 unmodified lines
231 int summary_log;232 int summary_log;
232 int summary_tags;233 int summary_tags;
233 int ssdiff;234 int ssdiff;
235 int commit_sort;
234 struct string_list mimetypes;236 struct string_list mimetypes;
235 struct cgit_filter *about_filter;237 struct cgit_filter *about_filter;
236 struct cgit_filter *commit_filter;238 struct cgit_filter *commit_filter;
cgitrc.5.txt+12−0
@@ -192,6 +192,12 @@ local-time:: · 191 unmodified lines
192 Flag which, if set to "1", makes cgit print commit and tag times in the192 Flag which, if set to "1", makes cgit print commit and tag times in the
193 servers timezone. Default value: "0".193 servers timezone. Default value: "0".
194 194
195commit-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
195logo::201logo::
196 Url which specifies the source of an image which will be used as a logo202 Url which specifies the source of an image which will be used as a logo
197 on all cgit pages. Default value: "/cgit.png".203 on all cgit pages. Default value: "/cgit.png".
@@ -435,6 +441,12 @@ repo.enable-subject-links:: · 237 unmodified lines
435 A flag which can be used to override the global setting441 A flag which can be used to override the global setting
436 `enable-subject-links'. Default value: none.442 `enable-subject-links'. Default value: none.
437 443
444repo.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
438repo.logo::450repo.logo::
439 Url which specifies the source of an image which will be used as a logo451 Url which specifies the source of an image which will be used as a logo
440 on this repo's pages. Default value: global logo.452 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
68{68{
69 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,69 cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
70 ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1,70 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);
72}73}
73 74
74static void ls_cache_fn(struct cgit_context *ctx)75static 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
63 ret->enable_remote_branches = ctx.cfg.enable_remote_branches;63 ret->enable_remote_branches = ctx.cfg.enable_remote_branches;
64 ret->enable_subject_links = ctx.cfg.enable_subject_links;64 ret->enable_subject_links = ctx.cfg.enable_subject_links;
65 ret->max_stats = ctx.cfg.max_stats;65 ret->max_stats = ctx.cfg.max_stats;
66 ret->commit_sort = ctx.cfg.commit_sort;
66 ret->module_link = ctx.cfg.module_link;67 ret->module_link = ctx.cfg.module_link;
67 ret->readme = ctx.cfg.readme;68 ret->readme = ctx.cfg.readme;
68 ret->mtime = -1;69 ret->mtime = -1;
ui-log.c+9−1
@@ -278,7 +278,7 @@ static char *next_token(char **src) · 277 unmodified lines
278}278}
279 279
280void cgit_print_log(const char *tip, int ofs, int cnt, char *grep, char *pattern,280void 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)
282{282{
283 struct rev_info rev;283 struct rev_info rev;
284 struct commit *commit;284 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
327 COLUMN_COLORS_HTML_MAX);327 COLUMN_COLORS_HTML_MAX);
328 }328 }
329 329
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
330 if (path) {338 if (path) {
331 arg = "--";339 arg = "--";
332 vector_push(&vec, &arg, 0);340 vector_push(&vec, &arg, 0);
ui-log.h+1−1
@@ -3,7 +3,7 @@ · 2 unmodified lines
3 3
4extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,4extern void cgit_print_log(const char *tip, int ofs, int cnt, char *grep,
5 char *pattern, char *path, int pager,5 char *pattern, char *path, int pager,
6 int commit_graph);6 int commit_graph, int commit_sort);
7extern void show_commit_decorations(struct commit *commit);7extern void show_commit_decorations(struct commit *commit);
8 8
9#endif /* UI_LOG_H */9#endif /* UI_LOG_H */
ui-summary.c+1−1
@@ -59,7 +59,7 @@ void cgit_print_summary() · 58 unmodified lines
59 if (ctx.cfg.summary_log > 0) {59 if (ctx.cfg.summary_log > 0) {
60 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");60 html("<tr class='nohover'><td colspan='4'>&nbsp;</td></tr>");
61 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,61 cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL,
62 NULL, NULL, 0, 0);62 NULL, NULL, 0, 0, 0);
63 }63 }
64 if (ctx.repo->clone_url)64 if (ctx.repo->clone_url)
65 print_urls(expand_macros(ctx.repo->clone_url), NULL);65 print_urls(expand_macros(ctx.repo->clone_url), NULL);