diff options
Diffstat (limited to 'source/ui-patch.c')
| -rw-r--r-- | source/ui-patch.c | 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 file changed, 12 insertions, 22 deletions
diff --git a/source/ui-patch.c b/source/ui-patch.c index bc98f2e..baa87c9 100644 --- a/source/ui-patch.c +++ b/source/ui-patch.c @@ -25,31 +25,27 @@ * for that one commit instead. */ static int resolve_range(const char *new_rev, const char *old_rev, - struct object_id *new_oid, struct object_id *old_oid) + struct object_id *new_oid, struct object_id *old_oid) { struct commit *commit; if (repo_get_oid(the_repository, new_rev, new_oid)) { - cgit_print_error_page(404, "Not Found", - "Bad object id: %s", new_rev); + cgit_print_error_page(404, "Not Found", "Bad object id: %s", new_rev); return -1; } commit = lookup_commit_reference(the_repository, new_oid); if (!commit) { - cgit_print_error_page(404, "Not Found", - "Bad commit reference: %s", new_rev); + cgit_print_error_page(404, "Not Found", "Bad commit reference: %s", new_rev); return -1; } if (old_rev) { if (repo_get_oid(the_repository, old_rev, old_oid)) { - cgit_print_error_page(404, "Not Found", - "Bad object id: %s", old_rev); + cgit_print_error_page(404, "Not Found", "Bad object id: %s", old_rev); return -1; } if (!lookup_commit_reference(the_repository, old_oid)) { - cgit_print_error_page(404, "Not Found", - "Bad commit reference: %s", old_rev); + cgit_print_error_page(404, "Not Found", "Bad commit reference: %s", old_rev); return -1; } } else if (commit->parents && commit->parents->item) { @@ -60,8 +56,7 @@ static int resolve_range(const char *new_rev, const char *old_rev, return 0; } -void cgit_print_patch(const char *new_rev, const char *old_rev, - const char *prefix) +void cgit_print_patch(const char *new_rev, const char *old_rev, const char *prefix) { struct rev_info rev; struct commit *commit; @@ -71,8 +66,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, // first entry stands in for the program name and is skipped, and the // array has to stay null terminated because the path after the double // dash is picked up past the count. - const char *rev_argv[] = { NULL, "--reverse", "--format=email", - rev_range, "--", prefix, NULL }; + const char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range, "--", prefix, NULL }; int rev_argc = ARRAY_SIZE(rev_argv) - 1; if (!prefix) @@ -87,8 +81,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (is_null_oid(&old_oid)) { memcpy(rev_range, oid_to_hex(&new_oid), the_hash_algo->hexsz + 1); } else { - xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s", - oid_to_hex(&old_oid), oid_to_hex(&new_oid)); + xsnprintf(rev_range, REV_RANGE_LEN, "%s..%s", oid_to_hex(&old_oid), oid_to_hex(&new_oid)); } ctx.page.mimetype = "text/plain"; @@ -97,9 +90,8 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, if (!ctx.cfg.enable_plain_email) { rev_argv[FORMAT_ARG] = - "--format=format:From %H Mon Sep 17 00:00:00 " - "2001%nFrom: %an%nDate: %aD%n%w(78,0,1)Subject: " - "%s%n%n%w(0)%b"; + "--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"; } repo_init_revisions(the_repository, &rev, NULL); @@ -108,15 +100,13 @@ void cgit_print_patch(const char *new_rev, const char *old_rev, rev.diff = 1; rev.show_root_diff = 1; rev.max_parents = 1; - rev.diffopt.output_format |= DIFF_FORMAT_DIFFSTAT | - DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY; + rev.diffopt.output_format |= DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH | DIFF_FORMAT_SUMMARY; if (prefix) // Allocated rather than formatted into cgit_fmt's fixed // buffer, because the path comes from the request and a long // one would abort the process here, with the headers for a // successful response already on the wire. - rev.diffopt.stat_sep = cgit_fmtalloc("(limited to '%s')\n\n", - prefix); + rev.diffopt.stat_sep = cgit_fmtalloc("(limited to '%s')\n\n", prefix); setup_revisions(rev_argc, rev_argv, &rev, NULL); // A single commit resolves to a range starting at its parent, so this // only ever cuts an explicit range short and keeps one request from |
