summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--cmd.c2
-rw-r--r--ui-commit.c2
-rw-r--r--ui-patch.c6
-rw-r--r--ui-patch.h2
-rw-r--r--ui-shared.c4
-rw-r--r--ui-shared.h2
6 files changed, 10 insertions, 8 deletions
diff --git a/cmd.c b/cmd.c
index 893ae25..605876b 100644
--- a/cmd.c
+++ b/cmd.c
@@ -69,49 +69,49 @@ static void log_fn(struct cgit_context *ctx)
cgit_print_log(ctx->qry.sha1, ctx->qry.ofs, ctx->cfg.max_commit_count,
ctx->qry.grep, ctx->qry.search, ctx->qry.path, 1);
}
static void ls_cache_fn(struct cgit_context *ctx)
{
ctx->page.mimetype = "text/plain";
ctx->page.filename = "ls-cache.txt";
cgit_print_http_headers(ctx);
cache_ls(ctx->cfg.cache_root);
}
static void objects_fn(struct cgit_context *ctx)
{
cgit_clone_objects(ctx);
}
static void repolist_fn(struct cgit_context *ctx)
{
cgit_print_repolist();
}
static void patch_fn(struct cgit_context *ctx)
{
- cgit_print_patch(ctx->qry.sha1);
+ cgit_print_patch(ctx->qry.sha1, ctx->qry.path);
}
static void plain_fn(struct cgit_context *ctx)
{
cgit_print_plain(ctx);
}
static void refs_fn(struct cgit_context *ctx)
{
cgit_print_refs();
}
static void snapshot_fn(struct cgit_context *ctx)
{
cgit_print_snapshot(ctx->qry.head, ctx->qry.sha1, ctx->qry.path,
ctx->repo->snapshots, ctx->qry.nohead);
}
static void stats_fn(struct cgit_context *ctx)
{
cgit_show_stats(ctx);
}
static void summary_fn(struct cgit_context *ctx)
diff --git a/ui-commit.c b/ui-commit.c
index 2f4c6d4..b3a2063 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -39,49 +39,49 @@ void cgit_print_commit(char *hex, const char *prefix)
html("<table summary='commit info' class='commit-info'>\n");
html("<tr><th>author</th><td>");
html_txt(info->author);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->author_email);
}
html("</td><td class='right'>");
cgit_print_date(info->author_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>committer</th><td>");
html_txt(info->committer);
if (!ctx.cfg.noplainemail) {
html(" ");
html_txt(info->committer_email);
}
html("</td><td class='right'>");
cgit_print_date(info->committer_date, FMT_LONGDATE, ctx.cfg.local_time);
html("</td></tr>\n");
html("<tr><th>commit</th><td colspan='2' class='sha1'>");
tmp = sha1_to_hex(commit->object.sha1);
cgit_commit_link(tmp, NULL, NULL, ctx.qry.head, tmp, 0);
html(" (");
- cgit_patch_link("patch", NULL, NULL, NULL, tmp);
+ cgit_patch_link("patch", NULL, NULL, NULL, tmp, prefix);
html(") (");
if ((ctx.qry.ssdiff && !ctx.cfg.ssdiff) || (!ctx.qry.ssdiff && ctx.cfg.ssdiff))
cgit_commit_link("unidiff", NULL, NULL, ctx.qry.head, tmp, 1);
else
cgit_commit_link("side-by-side diff", NULL, NULL, ctx.qry.head, tmp, 1);
html(")</td></tr>\n");
html("<tr><th>tree</th><td colspan='2' class='sha1'>");
tmp = xstrdup(hex);
cgit_tree_link(sha1_to_hex(commit->tree->object.sha1), NULL, NULL,
ctx.qry.head, tmp, NULL);
html("</td></tr>\n");
for (p = commit->parents; p ; p = p->next) {
parent = lookup_commit_reference(p->item->object.sha1);
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'>");
cgit_commit_link(sha1_to_hex(p->item->object.sha1), NULL, NULL,
ctx.qry.head, sha1_to_hex(p->item->object.sha1), 0);
html(" (");
diff --git a/ui-patch.c b/ui-patch.c
index 2a8f7a5..25dc9fe 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -56,74 +56,76 @@ static void header(unsigned char *sha1, char *path1, int mode1,
}
static void filepair_cb(struct diff_filepair *pair)
{
unsigned long old_size = 0;
unsigned long new_size = 0;
int binary = 0;
header(pair->one->sha1, pair->one->path, pair->one->mode,
pair->two->sha1, pair->two->path, pair->two->mode);
if (S_ISGITLINK(pair->one->mode) || S_ISGITLINK(pair->two->mode)) {
if (S_ISGITLINK(pair->one->mode))
print_line(fmt("-Subproject %s", sha1_to_hex(pair->one->sha1)), 52);
if (S_ISGITLINK(pair->two->mode))
print_line(fmt("+Subproject %s", sha1_to_hex(pair->two->sha1)), 52);
return;
}
if (cgit_diff_files(pair->one->sha1, pair->two->sha1, &old_size,
&new_size, &binary, print_line))
html("Error running diff");
if (binary)
html("Binary files differ\n");
}
-void cgit_print_patch(char *hex)
+void cgit_print_patch(char *hex, const char *prefix)
{
struct commit *commit;
struct commitinfo *info;
unsigned char sha1[20], old_sha1[20];
char *patchname;
if (!hex)
hex = ctx.qry.head;
if (get_sha1(hex, sha1)) {
cgit_print_error(fmt("Bad object id: %s", hex));
return;
}
commit = lookup_commit_reference(sha1);
if (!commit) {
cgit_print_error(fmt("Bad commit reference: %s", hex));
return;
}
info = cgit_parse_commit(commit);
if (commit->parents && commit->parents->item)
hashcpy(old_sha1, commit->parents->item->object.sha1);
else
hashclr(old_sha1);
patchname = fmt("%s.patch", sha1_to_hex(sha1));
ctx.page.mimetype = "text/plain";
ctx.page.filename = patchname;
cgit_print_http_headers(&ctx);
htmlf("From %s Mon Sep 17 00:00:00 2001\n", sha1_to_hex(sha1));
htmlf("From: %s", info->author);
if (!ctx.cfg.noplainemail) {
htmlf(" %s", info->author_email);
}
html("\n");
html("Date: ");
cgit_print_date(info->author_date, "%a, %d %b %Y %H:%M:%S %z%n", ctx.cfg.local_time);
htmlf("Subject: %s\n\n", info->subject);
if (info->msg && *info->msg) {
htmlf("%s", info->msg);
if (info->msg[strlen(info->msg) - 1] != '\n')
html("\n");
}
html("---\n");
- cgit_diff_tree(old_sha1, sha1, filepair_cb, NULL);
+ if (prefix)
+ htmlf("(limited to '%s')\n\n", prefix);
+ cgit_diff_tree(old_sha1, sha1, filepair_cb, prefix);
html("--\n");
htmlf("cgit %s\n", CGIT_VERSION);
cgit_free_commitinfo(info);
}
diff --git a/ui-patch.h b/ui-patch.h
index 9f68212..1641cea 100644
--- a/ui-patch.h
+++ b/ui-patch.h
@@ -1,6 +1,6 @@
#ifndef UI_PATCH_H
#define UI_PATCH_H
-extern void cgit_print_patch(char *hex);
+extern void cgit_print_patch(char *hex, const char *prefix);
#endif /* UI_PATCH_H */
diff --git a/ui-shared.c b/ui-shared.c
index 4fa506f..d5c4c10 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -367,51 +367,51 @@ void cgit_diff_link(const char *name, const char *title, const char *class,
delim = repolink(title, class, "diff", head, path);
if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
html(delim);
html("id=");
html_url_arg(new_rev);
delim = "&amp;";
}
if (old_rev) {
html(delim);
html("id2=");
html_url_arg(old_rev);
delim = "&amp;";
}
if ((ctx.qry.ssdiff && !toggle_ssdiff) || (!ctx.qry.ssdiff && toggle_ssdiff)) {
html(delim);
html("ss=1");
}
html("'>");
html_txt(name);
html("</a>");
}
void cgit_patch_link(const char *name, const char *title, const char *class,
- const char *head, const char *rev)
+ const char *head, const char *rev, const char *path)
{
- reporevlink("patch", name, title, class, head, rev, NULL);
+ reporevlink("patch", name, title, class, head, rev, path);
}
void cgit_stats_link(const char *name, const char *title, const char *class,
const char *head, const char *path)
{
reporevlink("stats", name, title, class, head, NULL, path);
}
void cgit_self_link(char *name, const char *title, const char *class,
struct cgit_context *ctx)
{
if (!strcmp(ctx->qry.page, "repolist"))
return cgit_index_link(name, title, class, ctx->qry.search,
ctx->qry.ofs);
else if (!strcmp(ctx->qry.page, "summary"))
return cgit_summary_link(name, title, class, ctx->qry.head);
else if (!strcmp(ctx->qry.page, "tag"))
return cgit_tag_link(name, title, class, ctx->qry.head,
ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL);
else if (!strcmp(ctx->qry.page, "tree"))
return cgit_tree_link(name, title, class, ctx->qry.head,
ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL,
ctx->qry.path);
else if (!strcmp(ctx->qry.page, "plain"))
diff --git a/ui-shared.h b/ui-shared.h
index 3df5464..c0e5c55 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -11,49 +11,49 @@ extern char *cgit_pageurl(const char *reponame, const char *pagename,
const char *query);
extern void cgit_index_link(const char *name, const char *title,
const char *class, const char *pattern, int ofs);
extern void cgit_summary_link(const char *name, const char *title,
const char *class, const char *head);
extern void cgit_tag_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev);
extern void cgit_tree_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
extern void cgit_plain_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
extern void cgit_log_link(const char *name, const char *title,
const char *class, const char *head, const char *rev,
const char *path, int ofs, const char *grep,
const char *pattern, int showmsg);
extern void cgit_commit_link(char *name, const char *title,
const char *class, const char *head,
const char *rev, int toggle_ssdiff);
extern void cgit_patch_link(const char *name, const char *title,
const char *class, const char *head,
- const char *rev);
+ const char *rev, const char *path);
extern void cgit_refs_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *path);
extern void cgit_snapshot_link(const char *name, const char *title,
const char *class, const char *head,
const char *rev, const char *archivename);
extern void cgit_diff_link(const char *name, const char *title,
const char *class, const char *head,
const char *new_rev, const char *old_rev,
const char *path, int toggle_ssdiff);
extern void cgit_stats_link(const char *name, const char *title,
const char *class, const char *head,
const char *path);
extern void cgit_self_link(char *name, const char *title,
const char *class, struct cgit_context *ctx);
extern void cgit_object_link(struct object *obj);
extern void cgit_print_error(const char *msg);
extern void cgit_print_date(time_t secs, const char *format, int local_time);
extern void cgit_print_age(time_t t, time_t max_relative, const char *format);
extern void cgit_print_http_headers(struct cgit_context *ctx);
extern void cgit_print_docstart(struct cgit_context *ctx);
extern void cgit_print_docend();
extern void cgit_print_pageheader(struct cgit_context *ctx);