|
11 | 11 | #include "html.h"
|
12 | 12 | #include "ui-shared.h"
|
13 | 13 |
|
14 |
| -void cgit_print_patch(char *hex, const char *old_rev, const char *prefix) |
| 14 | +void cgit_print_patch(const char *new_rev, const char *old_rev, |
| 15 | + const char *prefix) |
15 | 16 | {
|
16 | 17 | struct rev_info rev;
|
17 | 18 | struct commit *commit;
|
18 |
| - unsigned char sha1[20], old_sha1[20]; |
| 19 | + unsigned char new_rev_sha1[20], old_rev_sha1[20]; |
19 | 20 | char rev_range[2 * 40 + 3];
|
20 | 21 | char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range };
|
21 | 22 | char *patchname;
|
22 | 23 |
|
23 |
| - if (!hex) |
24 |
| - hex = ctx.qry.head; |
| 24 | + if (!new_rev) |
| 25 | + new_rev = ctx.qry.head; |
25 | 26 |
|
26 |
| - if (get_sha1(hex, sha1)) { |
27 |
| - cgit_print_error("Bad object id: %s", hex); |
| 27 | + if (get_sha1(new_rev, new_rev_sha1)) { |
| 28 | + cgit_print_error("Bad object id: %s", new_rev); |
28 | 29 | return;
|
29 | 30 | }
|
30 |
| - commit = lookup_commit_reference(sha1); |
| 31 | + commit = lookup_commit_reference(new_rev_sha1); |
31 | 32 | if (!commit) {
|
32 |
| - cgit_print_error("Bad commit reference: %s", hex); |
| 33 | + cgit_print_error("Bad commit reference: %s", new_rev); |
33 | 34 | return;
|
34 | 35 | }
|
35 | 36 |
|
36 | 37 | if (old_rev) {
|
37 |
| - if (get_sha1(old_rev, old_sha1)) { |
| 38 | + if (get_sha1(old_rev, old_rev_sha1)) { |
38 | 39 | cgit_print_error("Bad object id: %s", old_rev);
|
39 | 40 | return;
|
40 | 41 | }
|
41 |
| - if (!lookup_commit_reference(old_sha1)) { |
| 42 | + if (!lookup_commit_reference(old_rev_sha1)) { |
42 | 43 | cgit_print_error("Bad commit reference: %s", old_rev);
|
43 | 44 | return;
|
44 | 45 | }
|
45 | 46 | } else if (commit->parents && commit->parents->item) {
|
46 |
| - hashcpy(old_sha1, commit->parents->item->object.sha1); |
| 47 | + hashcpy(old_rev_sha1, commit->parents->item->object.sha1); |
47 | 48 | } else {
|
48 |
| - hashclr(old_sha1); |
| 49 | + hashclr(old_rev_sha1); |
49 | 50 | }
|
50 | 51 |
|
51 |
| - if (is_null_sha1(old_sha1)) { |
52 |
| - memcpy(rev_range, sha1_to_hex(sha1), 41); |
| 52 | + if (is_null_sha1(old_rev_sha1)) { |
| 53 | + memcpy(rev_range, sha1_to_hex(new_rev_sha1), 41); |
53 | 54 | } else {
|
54 |
| - sprintf(rev_range, "%s..%s", sha1_to_hex(old_sha1), |
55 |
| - sha1_to_hex(sha1)); |
| 55 | + sprintf(rev_range, "%s..%s", sha1_to_hex(old_rev_sha1), |
| 56 | + sha1_to_hex(new_rev_sha1)); |
56 | 57 | }
|
57 | 58 |
|
58 | 59 | patchname = fmt("%s.patch", rev_range);
|
|
0 commit comments