diff options
context:
space:
mode:
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
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.
Diffstat (limited to '')
-rw-r--r--source/ui-diff.c7
1 file changed, 5 insertions, 2 deletions
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;
}