From 22773596fe2e472bb9a41894c7b09b656890a056 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Thu, 1 Oct 2026 16:20:14 -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 v2.8.0