Diff options
Diffstat (limited to 'source/ui-patch.c')
| -rw-r--r-- | source/ui-patch.c | 13 |
1 file changed, 13 insertions, 0 deletions
diff --git a/source/ui-patch.c b/source/ui-patch.c index 0fa9a2e..a60e7cc 100644 --- a/source/ui-patch.c +++ b/source/ui-patch.c @@ -12,6 +12,7 @@ #include "html.h" #include "ui-patch.h" #include "ui-shared.h" +#include "shared.h" // Room for two hex object ids, the two dots between them, and the null byte. #define REV_RANGE_LEN (2 * GIT_MAX_HEXSZ + 3) @@ -24,6 +25,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref struct strvec rev_argv = STRVEC_INIT; char rev_range[REV_RANGE_LEN]; const char *version; + char *source = NULL; if (!new_rev) new_rev = ctx.qry.head; @@ -47,9 +49,20 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, const char *pref else strvec_push(&rev_argv, "--format=format:From %H Mon Sep 17 00:00:00 2001%n" "From: %an%nDate: %aD%n%w(78,0,1)Subject: %s%n%n%w(0)%b"); + // A file the change renamed is limited by its old name as well, with + // rename detection on, so that git pairs the two into the rename. That + // name comes from the tree rather than the request, so it is matched + // literally. + if (prefix) + source = cgit_rename_source(&old_oid, &new_oid, prefix); + if (source) + strvec_push(&rev_argv, "-M"); strvec_pushl(&rev_argv, rev_range, "--", NULL); if (prefix) strvec_push(&rev_argv, prefix); + if (source) + strvec_pushf(&rev_argv, ":(literal)%s", source); + free(source); // Git inlines a blob up to its own big-file threshold, far past what // any other view inflates, so max-blob-size is applied through it. |
