From b275e66df0ad3f000d1e0fa964c58b04711066e5 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Wed, 23 Sep 2026 19:13:47 -1000 Subject: Limit rawdiff to the requested path The diff and patch pages honour the path in the url, which the parameter table documents for every page, but rawdiff never handed it to git and answered with the whole diff. --- source/ui-diff.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'source/ui-diff.c') diff --git a/source/ui-diff.c b/source/ui-diff.c index 5c9cd1c..a5202b5 100644 --- a/source/ui-diff.c +++ b/source/ui-diff.c @@ -535,13 +535,16 @@ static void filepair_cb(struct diff_filepair *pair) end_file(); } -static void print_raw_patch(const struct object_id *old_tree_oid, const struct object_id *new_tree_oid) +static void print_raw_patch(const struct object_id *old_tree_oid, const struct object_id *new_tree_oid, + const char *prefix) { struct diff_options diffopt; repo_diff_setup(the_repository, &diffopt); diffopt.output_format = DIFF_FORMAT_PATCH; diffopt.flags.recursive = 1; + if (prefix) + cgit_diff_limit_path(&diffopt, prefix); diff_setup_done(&diffopt); ctx.page.mimetype = "text/plain"; @@ -683,7 +686,7 @@ void cgit_print_diff(const char *new_rev, const char *old_rev, const char *prefi cap_diffs = !path || prefix_is_dir(old_tree_oid, new_tree_oid, path); if (raw) { - print_raw_patch(old_tree_oid, new_tree_oid); + print_raw_patch(old_tree_oid, new_tree_oid, path); return; } -- cgit 2.12.1