summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2010-02-27 12:12:55 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2010-02-27 12:12:55 (UTC)
commit581a0c2a5428917d42cbfb2b4673a2d2ebceb7d0 (patch) (side-by-side diff)
treeed8ba775c729ea391209066aea9e58ed70ed1a5c
parente15842af627de03845b9c949f1f1596d94e3be02 (diff)
downloadcgit-581a0c2a5428917d42cbfb2b4673a2d2ebceb7d0.zip
cgit-581a0c2a5428917d42cbfb2b4673a2d2ebceb7d0.tar.gz
cgit-581a0c2a5428917d42cbfb2b4673a2d2ebceb7d0.tar.bz2
Optionally generate verbose parent links
The new option 'enable-subject-links' must be used to enable the verbose parent-links in commit view. Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cgit.c4
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt10
-rw-r--r--shared.c1
-rw-r--r--ui-commit.c12
5 files changed, 24 insertions, 5 deletions
diff --git a/cgit.c b/cgit.c
index 9305d0a..6ccf4aa 100644
--- a/cgit.c
+++ b/cgit.c
@@ -57,16 +57,18 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
else if (!strcmp(name, "snapshots"))
repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-log-filecount"))
repo->enable_log_filecount = ctx.cfg.enable_log_filecount * atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
repo->enable_log_linecount = ctx.cfg.enable_log_linecount * atoi(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);
else if (!strcmp(name, "module-link"))
repo->module_link= xstrdup(value);
else if (!strcmp(name, "section"))
repo->section = xstrdup(value);
else if (!strcmp(name, "readme") && value != NULL) {
if (*value == '/')
@@ -136,16 +138,18 @@ void config_cb(const char *name, const char *value)
else if (!strcmp(name, "enable-index-links"))
ctx.cfg.enable_index_links = atoi(value);
else if (!strcmp(name, "enable-log-filecount"))
ctx.cfg.enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
ctx.cfg.enable_log_linecount = atoi(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);
else if (!strcmp(name, "max-stats"))
ctx.cfg.max_stats = cgit_find_stats_period(value, NULL);
else if (!strcmp(name, "cache-size"))
ctx.cfg.cache_size = atoi(value);
else if (!strcmp(name, "cache-root"))
ctx.cfg.cache_root = xstrdup(value);
diff --git a/cgit.h b/cgit.h
index cd4af72..9b1e3f8 100644
--- a/cgit.h
+++ b/cgit.h
@@ -68,16 +68,17 @@ struct cgit_repo {
char *module_link;
char *readme;
char *section;
char *clone_url;
int snapshots;
int enable_log_filecount;
int enable_log_linecount;
int enable_remote_branches;
+ int enable_subject_links;
int max_stats;
time_t mtime;
struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
};
typedef void (*repo_config_fn)(struct cgit_repo *repo, const char *name,
@@ -176,16 +177,17 @@ struct cgit_config {
int cache_scanrc_ttl;
int cache_static_ttl;
int embedded;
int enable_filter_overrides;
int enable_index_links;
int enable_log_filecount;
int enable_log_linecount;
int enable_remote_branches;
+ int enable_subject_links;
int enable_tree_linenumbers;
int local_time;
int max_repo_count;
int max_commit_count;
int max_lock_attempts;
int max_msg_len;
int max_repodesc_len;
int max_blob_size;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index d74d9e7..fcd4308 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -110,16 +110,22 @@ enable-log-linecount::
and removed lines for each commit on the repository log page. Default
value: "0".
enable-remote-branches::
Flag which, when set to "1", will make cgit display remote branches
in the summary and refs views. Default value: "0". See also:
"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
for plaintext blobs printed in the tree view. Default value: "1".
favicon::
Url used as link to a shortcut icon for cgit. If specified, it is
suggested to use the value "/favicon.ico" since certain browsers will
ignore other values. Default value: none.
@@ -316,16 +322,20 @@ repo.enable-log-filecount::
repo.enable-log-linecount::
A flag which can be used to disable the global setting
`enable-log-linecount'. Default value: none.
repo.enable-remote-branches::
Flag which, when set to "1", will make cgit display 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
to the values specified for the global "max-stats" setting. Default
value: none.
repo.name::
The value to show as repository name. Default value: <repo.url>.
diff --git a/shared.c b/shared.c
index 5f46793..83ded44 100644
--- a/shared.c
+++ b/shared.c
@@ -55,16 +55,17 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->desc = "[no description]";
ret->owner = NULL;
ret->section = ctx.cfg.section;
ret->defbranch = "master";
ret->snapshots = ctx.cfg.snapshots;
ret->enable_log_filecount = ctx.cfg.enable_log_filecount;
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;
ret->readme = NULL;
ret->mtime = -1;
ret->about_filter = ctx.cfg.about_filter;
ret->commit_filter = ctx.cfg.commit_filter;
ret->source_filter = ctx.cfg.source_filter;
return ret;
diff --git a/ui-commit.c b/ui-commit.c
index 4d4970f..41313b9 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -13,17 +13,17 @@
#include "ui-log.h"
void cgit_print_commit(char *hex)
{
struct commit *commit, *parent;
struct commitinfo *info, *parent_info;
struct commit_list *p;
unsigned char sha1[20];
- char *tmp;
+ char *tmp, *tmp2;
int parents = 0;
if (!hex)
hex = ctx.qry.head;
if (get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return;
@@ -77,20 +77,22 @@ void cgit_print_commit(char *hex)
if (!parent) {
html("<tr><td colspan='3'>");
cgit_print_error("Error reading parent commit");
html("</td></tr>");
continue;
}
html("<tr><th>parent</th>"
"<td colspan='2' class='sha1'>");
- parent_info = cgit_parse_commit(parent);
- tmp = sha1_to_hex(p->item->object.sha1);
- cgit_commit_link(parent_info->subject, NULL, NULL,
- ctx.qry.head, tmp, 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,
sha1_to_hex(p->item->object.sha1), NULL, 0);
html(")</td></tr>");
parents++;
}
if (ctx.repo->snapshots) {
html("<tr><th>download</th><td colspan='2' class='sha1'>");