summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--cgit.c9
-rw-r--r--cgit.css5
-rw-r--r--cgit.h4
-rw-r--r--cgitrc.5.txt14
-rw-r--r--cmd.c2
-rw-r--r--scan-tree.c2
-rw-r--r--shared.c9
-rw-r--r--ui-atom.c4
-rw-r--r--ui-commit.c13
-rw-r--r--ui-plain.c68
11 files changed, 115 insertions, 17 deletions
diff --git a/Makefile b/Makefile
index 0a5055b..3a4d974 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,2 @@
-CGIT_VERSION = v0.8.3.1
+CGIT_VERSION = v0.8.3.2
CGIT_SCRIPT_NAME = cgit.cgi
diff --git a/cgit.c b/cgit.c
index 2c3ad73..d4fcfa7 100644
--- a/cgit.c
+++ b/cgit.c
@@ -64,2 +64,4 @@ void repo_config(struct cgit_repo *repo, const char *name, const char *value)
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"))
@@ -143,2 +145,4 @@ void config_cb(const char *name, const char *value)
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"))
@@ -167,2 +171,4 @@ void config_cb(const char *name, const char *value)
ctx.cfg.embedded = atoi(value);
+ else if (!strcmp(name, "max-atom-items"))
+ ctx.cfg.max_atom_items = atoi(value);
else if (!strcmp(name, "max-message-length"))
@@ -252,2 +258,4 @@ static void querystring_cb(const char *name, const char *value)
ctx.qry.ssdiff = atoi(value);
+ } else if (!strcmp(name, "all")) {
+ ctx.qry.show_all = atoi(value);
}
@@ -294,2 +302,3 @@ static void prepare_context(struct cgit_context *ctx)
ctx->cfg.summary_tags = 10;
+ ctx->cfg.max_atom_items = 10;
ctx->cfg.ssdiff = 0;
diff --git a/cgit.css b/cgit.css
index 28a2eeb..6e47eb3 100644
--- a/cgit.css
+++ b/cgit.css
@@ -533,3 +533,6 @@ a.deco {
-div.commit-subject a {
+div.commit-subject a.branch-deco,
+div.commit-subject a.tag-deco,
+div.commit-subject a.remote-deco,
+div.commit-subject a.deco {
margin-left: 1em;
diff --git a/cgit.h b/cgit.h
index f990b15..80c3902 100644
--- a/cgit.h
+++ b/cgit.h
@@ -75,2 +75,3 @@ struct cgit_repo {
int enable_remote_branches;
+ int enable_subject_links;
int max_stats;
@@ -147,2 +148,3 @@ struct cgit_query {
int ssdiff;
+ int show_all;
char *vpath;
@@ -184,4 +186,6 @@ struct cgit_config {
int enable_remote_branches;
+ int enable_subject_links;
int enable_tree_linenumbers;
int local_time;
+ int max_atom_items;
int max_repo_count;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 1f7ac1e..a853522 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -117,2 +117,8 @@ 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::
@@ -168,2 +174,6 @@ logo-link::
+max-atom-items::
+ Specifies the number of items to display in atom feeds view. Default
+ value: "10".
+
max-commit-count::
@@ -323,2 +333,6 @@ repo.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::
diff --git a/cmd.c b/cmd.c
index 605876b..6dc9f5e 100644
--- a/cmd.c
+++ b/cmd.c
@@ -35,3 +35,3 @@ static void atom_fn(struct cgit_context *ctx)
{
- cgit_print_atom(ctx->qry.head, ctx->qry.path, 10);
+ cgit_print_atom(ctx->qry.head, ctx->qry.path, ctx->cfg.max_atom_items);
}
diff --git a/scan-tree.c b/scan-tree.c
index dbca797..1e18f3c 100644
--- a/scan-tree.c
+++ b/scan-tree.c
@@ -58,2 +58,4 @@ static void add_repo(const char *base, const char *path, repo_config_fn fn)
}
+ if (!stat(fmt("%s/noweb", path), &st))
+ return;
if ((pwd = getpwuid(st.st_uid)) == NULL) {
diff --git a/shared.c b/shared.c
index 6e8f0ce..58837dc 100644
--- a/shared.c
+++ b/shared.c
@@ -61,2 +61,3 @@ struct cgit_repo *cgit_add_repo(const char *url)
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;
@@ -280,2 +281,6 @@ int cgit_diff_files(const unsigned char *old_sha1,
*binary = 1;
+ if (file1.size)
+ free(file1.ptr);
+ if (file2.size)
+ free(file2.ptr);
return 0;
@@ -292,2 +297,6 @@ int cgit_diff_files(const unsigned char *old_sha1,
xdl_diff(&file1, &file2, &diff_params, &emit_params, &emit_cb);
+ if (file1.size)
+ free(file1.ptr);
+ if (file2.size)
+ free(file2.ptr);
return 0;
diff --git a/ui-atom.c b/ui-atom.c
index 808b2d0..9f049ae 100644
--- a/ui-atom.c
+++ b/ui-atom.c
@@ -87,3 +87,5 @@ void cgit_print_atom(char *tip, char *path, int max_count)
- if (!tip)
+ if (ctx.qry.show_all)
+ argv[1] = "--all";
+ else if (!tip)
argv[1] = ctx.qry.head;
diff --git a/ui-commit.c b/ui-commit.c
index 2d98ed9..a11bc5f 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -17,6 +17,6 @@ void cgit_print_commit(char *hex, const char *prefix)
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;
@@ -88,5 +88,8 @@ void cgit_print_commit(char *hex, const char *prefix)
"<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), prefix, 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, prefix, 0);
html(" (");
diff --git a/ui-plain.c b/ui-plain.c
index 66cb19c..da76406 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -12,4 +12,3 @@
-char *curr_rev;
-char *match_path;
+int match_baselen;
int match;
@@ -55,2 +54,34 @@ static void print_object(const unsigned char *sha1, const char *path)
+static void print_dir(const unsigned char *sha1, const char *path,
+ const char *base)
+{
+ char *fullpath;
+ if (path[0] || base[0])
+ fullpath = fmt("/%s%s/", base, path);
+ else
+ fullpath = "/";
+ ctx.page.etag = sha1_to_hex(sha1);
+ cgit_print_http_headers(&ctx);
+ htmlf("<html><head><title>%s</title></head>\n<body>\n"
+ " <h2>%s</h2>\n <ul>\n", fullpath, fullpath);
+ if (path[0] || base[0])
+ html(" <li><a href=\"../\">../</a></li>\n");
+ match = 2;
+}
+
+static void print_dir_entry(const unsigned char *sha1, const char *path,
+ unsigned mode)
+{
+ const char *sep = "";
+ if (S_ISDIR(mode))
+ sep = "/";
+ htmlf(" <li><a href=\"%s%s\">%s%s</a></li>\n", path, sep, path, sep);
+ match = 2;
+}
+
+static void print_dir_tail(void)
+{
+ html(" </ul>\n</body></html>\n");
+}
+
static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
@@ -59,9 +90,23 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
{
- if (S_ISDIR(mode))
+ if (baselen == match_baselen) {
+ if (S_ISREG(mode))
+ print_object(sha1, pathname);
+ else if (S_ISDIR(mode)) {
+ print_dir(sha1, pathname, base);
+ return READ_TREE_RECURSIVE;
+ }
+ }
+ else if (baselen > match_baselen)
+ print_dir_entry(sha1, pathname, mode);
+ else if (S_ISDIR(mode))
return READ_TREE_RECURSIVE;
- if (S_ISREG(mode) && !strncmp(base, match_path, baselen) &&
- !strcmp(pathname, match_path + baselen))
- print_object(sha1, pathname);
+ return 0;
+}
+static int basedir_len(const char *path)
+{
+ char *p = strrchr(path, '/');
+ if (p)
+ return p - path + 1;
return 0;
@@ -79,3 +124,2 @@ void cgit_print_plain(struct cgit_context *ctx)
- curr_rev = xstrdup(rev);
if (get_sha1(rev, sha1)) {
@@ -89,3 +133,9 @@ void cgit_print_plain(struct cgit_context *ctx)
}
- match_path = ctx->qry.path;
+ if (!paths[0]) {
+ paths[0] = "";
+ match_baselen = -1;
+ print_dir(commit->tree->object.sha1, "", "");
+ }
+ else
+ match_baselen = basedir_len(paths[0]);
read_tree_recursive(commit->tree, "", 0, 0, paths, walk_tree, NULL);
@@ -93,2 +143,4 @@ void cgit_print_plain(struct cgit_context *ctx)
html_status(404, "Not found", 0);
+ else if (match == 2)
+ print_dir_tail();
}