aboutsummaryrefslogtreecommitdiffstats
path: root/ui-patch.c
diff options
context:
space:
mode:
authorChristian Hesse2016-09-29 21:51:41 +0200
committerChristian Hesse2016-10-04 09:47:18 +0200
commit85793b8181aa93ef6070f137fcb3caee624849b6 (patch)
tree42b5753d00c2d2135a79f551af924f47afefc646 /ui-patch.c
parent1a9a75d7c7c33cd89f1c34445d56e51dc349dc31 (diff)
downloadcgit-85793b8181aa93ef6070f137fcb3caee624849b6.tar.gz
cgit-85793b8181aa93ef6070f137fcb3caee624849b6.tar.bz2
cgit-85793b8181aa93ef6070f137fcb3caee624849b6.zip
ui-patch: replace 'unsigned char sha1[20]' with 'struct object_id oid'
Upstream git is replacing 'unsigned char sha1[20]' with 'struct object_id oid'. We have some code that can be changed independent from upstream. So here we go...
Diffstat (limited to 'ui-patch.c')
-rw-r--r--ui-patch.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ui-patch.c b/ui-patch.c
index 4c051e8..fd6316b 100644
--- a/ui-patch.c
+++ b/ui-patch.c
@@ -16,7 +16,7 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
16{ 16{
17 struct rev_info rev; 17 struct rev_info rev;
18 struct commit *commit; 18 struct commit *commit;
19 unsigned char new_rev_sha1[20], old_rev_sha1[20]; 19 struct object_id new_rev_oid, old_rev_oid;
20 char rev_range[2 * 40 + 3]; 20 char rev_range[2 * 40 + 3];
21 char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range }; 21 char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range };
22 char *patchname; 22 char *patchname;
@@ -24,12 +24,12 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
24 if (!new_rev) 24 if (!new_rev)
25 new_rev = ctx.qry.head; 25 new_rev = ctx.qry.head;
26 26
27 if (get_sha1(new_rev, new_rev_sha1)) { 27 if (get_oid(new_rev, &new_rev_oid)) {
28 cgit_print_error_page(404, "Not found", 28 cgit_print_error_page(404, "Not found",
29 "Bad object id: %s", new_rev); 29 "Bad object id: %s", new_rev);
30 return; 30 return;
31 } 31 }
32 commit = lookup_commit_reference(new_rev_sha1); 32 commit = lookup_commit_reference(new_rev_oid.hash);
33 if (!commit) { 33 if (!commit) {
34 cgit_print_error_page(404, "Not found", 34 cgit_print_error_page(404, "Not found",
35 "Bad commit reference: %s", new_rev); 35 "Bad commit reference: %s", new_rev);
@@ -37,27 +37,27 @@ void cgit_print_patch(const char *new_rev, const char *old_rev,
37 } 37 }
38 38
39 if (old_rev) { 39 if (old_rev) {
40 if (get_sha1(old_rev, old_rev_sha1)) { 40 if (get_oid(old_rev, &old_rev_oid)) {
41 cgit_print_error_page(404, "Not found", 41 cgit_print_error_page(404, "Not found",
42 "Bad object id: %s", old_rev); 42 "Bad object id: %s", old_rev);
43 return; 43 return;
44 } 44 }
45 if (!lookup_commit_reference(old_rev_sha1)) { 45 if (!lookup_commit_reference(old_rev_oid.hash)) {
46 cgit_print_error_page(404, "Not found", 46 cgit_print_error_page(404, "Not found",
47 "Bad commit reference: %s", old_rev); 47 "Bad commit reference: %s", old_rev);
48 return; 48 return;
49 } 49 }
50 } else if (commit->parents && commit->parents->item) { 50 } else if (commit->parents && commit->parents->item) {
51 hashcpy(old_rev_sha1, commit->parents->item->object.oid.hash); 51 oidcpy(&old_rev_oid, &commit->parents->item->object.oid);
52 } else { 52 } else {
53 hashclr(old_rev_sha1); 53 oidclr(&old_rev_oid);
54 } 54 }
55 55
56 if (is_null_sha1(old_rev_sha1)) { 56 if (is_null_oid(&old_rev_oid)) {
57 memcpy(rev_range, sha1_to_hex(new_rev_sha1), 41); 57 memcpy(rev_range, oid_to_hex(&new_rev_oid), GIT_SHA1_HEXSZ + 1);
58 } else { 58 } else {
59 sprintf(rev_range, "%s..%s", sha1_to_hex(old_rev_sha1), 59 sprintf(rev_range, "%s..%s", oid_to_hex(&old_rev_oid),
60 sha1_to_hex(new_rev_sha1)); 60 oid_to_hex(&new_rev_oid));
61 } 61 }
62 62
63 patchname = fmt("%s.patch", rev_range); 63 patchname = fmt("%s.patch", rev_range);