-rw-r--r-- | cmd.c | 2 | ||||
-rw-r--r-- | ui-commit.c | 2 | ||||
-rw-r--r-- | ui-patch.c | 6 | ||||
-rw-r--r-- | ui-patch.h | 2 | ||||
-rw-r--r-- | ui-shared.c | 4 | ||||
-rw-r--r-- | ui-shared.h | 2 |
6 files changed, 10 insertions, 8 deletions
@@ -45,97 +45,97 @@ static void about_fn(struct cgit_context *ctx) } static void blob_fn(struct cgit_context *ctx) { cgit_print_blob(ctx->qry.sha1, ctx->qry.path, ctx->qry.head); } static void commit_fn(struct cgit_context *ctx) { cgit_print_commit(ctx->qry.sha1, ctx->qry.path); } static void diff_fn(struct cgit_context *ctx) { cgit_print_diff(ctx->qry.sha1, ctx->qry.sha2, ctx->qry.path); } static void info_fn(struct cgit_context *ctx) { cgit_clone_info(ctx); } 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) { cgit_print_summary(); } static void tag_fn(struct cgit_context *ctx) { cgit_print_tag(ctx->qry.sha1); } static void tree_fn(struct cgit_context *ctx) { cgit_print_tree(ctx->qry.sha1, ctx->qry.path); } #define def_cmd(name, want_repo, want_layout, want_vpath) \ {#name, name##_fn, want_repo, want_layout, want_vpath} struct cgit_cmd *cgit_get_cmd(struct cgit_context *ctx) { static struct cgit_cmd cmds[] = { def_cmd(HEAD, 1, 0, 0), def_cmd(atom, 1, 0, 0), def_cmd(about, 0, 1, 0), def_cmd(blob, 1, 0, 0), diff --git a/ui-commit.c b/ui-commit.c index 2f4c6d4..b3a2063 100644 --- a/ui-commit.c +++ b/ui-commit.c @@ -15,97 +15,97 @@ void cgit_print_commit(char *hex, const char *prefix) { struct commit *commit, *parent; struct commitinfo *info; struct commit_list *p; unsigned char sha1[20]; char *tmp; int parents = 0; 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); load_ref_decorations(DECORATE_FULL_REFS); 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(" ("); 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'>"); cgit_print_snapshot_links(ctx.qry.repo, ctx.qry.head, hex, ctx.repo->snapshots); html("</td></tr>"); } html("</table>\n"); html("<div class='commit-subject'>"); if (ctx.repo->commit_filter) cgit_open_filter(ctx.repo->commit_filter); html_txt(info->subject); if (ctx.repo->commit_filter) cgit_close_filter(ctx.repo->commit_filter); show_commit_decorations(commit); html("</div>"); html("<div class='commit-msg'>"); if (ctx.repo->commit_filter) cgit_open_filter(ctx.repo->commit_filter); html_txt(info->msg); @@ -32,98 +32,100 @@ static void header(unsigned char *sha1, char *path1, int mode1, path1 = "dev/null"; if (is_null_sha1(sha2)) path2 = "dev/null"; if (mode1 == 0) htmlf("new file mode %.6o\n", mode2); if (mode2 == 0) htmlf("deleted file mode %.6o\n", mode1); if (!subproject) { abbrev1 = xstrdup(find_unique_abbrev(sha1, DEFAULT_ABBREV)); abbrev2 = xstrdup(find_unique_abbrev(sha2, DEFAULT_ABBREV)); htmlf("index %s..%s", abbrev1, abbrev2); free(abbrev1); free(abbrev2); if (mode1 != 0 && mode2 != 0) { htmlf(" %.6o", mode1); if (mode2 != mode1) htmlf("..%.6o", mode2); } htmlf("\n--- a/%s\n", path1); htmlf("+++ b/%s\n", path2); } } 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); } @@ -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 @@ -343,99 +343,99 @@ void cgit_commit_link(char *name, const char *title, const char *class, } html("'>"); html_txt(name); html("</a>"); } void cgit_refs_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *path) { reporevlink("refs", name, title, class, head, rev, path); } void cgit_snapshot_link(const char *name, const char *title, const char *class, const char *head, const char *rev, const char *archivename) { reporevlink("snapshot", name, title, class, head, rev, archivename); } 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) { char *delim; 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 = "&"; } if (old_rev) { html(delim); html("id2="); html_url_arg(old_rev); delim = "&"; } 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")) return cgit_plain_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, ctx->qry.path); else if (!strcmp(ctx->qry.page, "log")) return cgit_log_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, ctx->qry.path, ctx->qry.ofs, ctx->qry.grep, ctx->qry.search, ctx->qry.showmsg); else if (!strcmp(ctx->qry.page, "commit")) return cgit_commit_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, ctx->qry.path, 0); else if (!strcmp(ctx->qry.page, "patch")) return cgit_patch_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, ctx->qry.path); else if (!strcmp(ctx->qry.page, "refs")) return cgit_refs_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, ctx->qry.path); else if (!strcmp(ctx->qry.page, "snapshot")) return cgit_snapshot_link(name, title, class, ctx->qry.head, ctx->qry.has_sha1 ? ctx->qry.sha1 : NULL, diff --git a/ui-shared.h b/ui-shared.h index 3df5464..c0e5c55 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -1,65 +1,65 @@ #ifndef UI_SHARED_H #define UI_SHARED_H extern char *cgit_httpscheme(); extern char *cgit_hosturl(); extern char *cgit_rooturl(); extern char *cgit_repourl(const char *reponame); extern char *cgit_fileurl(const char *reponame, const char *pagename, const char *filename, const char *query); 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); extern void cgit_print_filemode(unsigned short mode); extern void cgit_print_snapshot_links(const char *repo, const char *head, const char *hex, int snapshots); extern void cgit_add_hidden_formfields(int incl_head, int incl_search, const char *page); #endif /* UI_SHARED_H */ |