author | Lars Hjemli <hjemli@gmail.com> | 2010-06-19 09:38:46 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2010-06-19 09:38:46 (UTC) |
commit | 9af580d8f6e31ccd68307a728a710c525e4133ab (patch) (side-by-side diff) | |
tree | 30b5fb3d0d323423da7ee52ba9a45b36bb557252 | |
parent | 023d933121ca7352a069f3886caf6fbe958ba27d (diff) | |
parent | 581a0c2a5428917d42cbfb2b4673a2d2ebceb7d0 (diff) | |
download | cgit-9af580d8f6e31ccd68307a728a710c525e4133ab.zip cgit-9af580d8f6e31ccd68307a728a710c525e4133ab.tar.gz cgit-9af580d8f6e31ccd68307a728a710c525e4133ab.tar.bz2 |
Merge branch 'sn/subject-link'
-rw-r--r-- | cgit.c | 4 | ||||
-rw-r--r-- | cgit.h | 2 | ||||
-rw-r--r-- | cgitrc.5.txt | 10 | ||||
-rw-r--r-- | shared.c | 1 | ||||
-rw-r--r-- | ui-commit.c | 12 |
5 files changed, 25 insertions, 4 deletions
@@ -63,4 +63,6 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value) else if (!strcmp(name, "enable-remote-branches")) repo->enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + repo->enable_subject_links = atoi(value); else if (!strcmp(name, "max-stats")) repo->max_stats = cgit_find_stats_period(value, NULL); @@ -142,4 +144,6 @@ void config_cb(const char *name, const char *value) else if (!strcmp(name, "enable-remote-branches")) ctx.cfg.enable_remote_branches = atoi(value); + else if (!strcmp(name, "enable-subject-links")) + ctx.cfg.enable_subject_links = atoi(value); else if (!strcmp(name, "enable-tree-linenumbers")) ctx.cfg.enable_tree_linenumbers = atoi(value); @@ -74,4 +74,5 @@ struct cgit_repo { int enable_log_linecount; int enable_remote_branches; + int enable_subject_links; int max_stats; time_t mtime; @@ -182,4 +183,5 @@ struct cgit_config { int enable_log_linecount; int enable_remote_branches; + int enable_subject_links; int enable_tree_linenumbers; int local_time; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index d74d9e7..fcd4308 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -116,4 +116,10 @@ enable-remote-branches:: "repo.enable-remote-branches". +enable-subject-links:: + Flag which, when set to "1", will make cgit use the subject of the + parent commit as link text when generating links to parent commits + in commit view. Default value: "0". See also: + "repo.enable-subject-links". + enable-tree-linenumbers:: Flag which, when set to "1", will make cgit generate linenumber links @@ -322,4 +328,8 @@ repo.enable-remote-branches:: in the summary and refs views. Default value: <enable-remote-branches>. +repo.enable-subject-links:: + A flag which can be used to override the global setting + `enable-subject-links'. Default value: none. + repo.max-stats:: Override the default maximum statistics period. Valid values are equal @@ -61,4 +61,5 @@ struct cgit_repo *cgit_add_repo(const char *url) ret->enable_log_linecount = ctx.cfg.enable_log_linecount; ret->enable_remote_branches = ctx.cfg.enable_remote_branches; + ret->enable_subject_links = ctx.cfg.enable_subject_links; ret->max_stats = ctx.cfg.max_stats; ret->module_link = ctx.cfg.module_link; diff --git a/ui-commit.c b/ui-commit.c index b5e3c01..41313b9 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -16,8 +16,8 @@ void cgit_print_commit(char *hex) { struct commit *commit, *parent; - struct commitinfo *info; + struct commitinfo *info, *parent_info; struct commit_list *p; unsigned char sha1[20]; - char *tmp; + char *tmp, *tmp2; int parents = 0; @@ -83,6 +83,10 @@ void cgit_print_commit(char *hex) html("<tr><th>parent</th>" "<td colspan='2' class='sha1'>"); - cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL, - ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0); + tmp = tmp2 = sha1_to_hex(p->item->object.sha1); + if (ctx.repo->enable_subject_links) { + parent_info = cgit_parse_commit(parent); + tmp2 = parent_info->subject; + } + cgit_commit_link(tmp2, NULL, NULL, ctx.qry.head, tmp, 0); html(" ("); cgit_diff_link("diff", NULL, NULL, ctx.qry.head, hex, |