Skip to content

Commit 4e00d33

Browse files
Lukas Fleischerzx2c4
Lukas Fleischer
authored andcommitted
ui-patch: Rename variables
Rename parameters and local variables to match those from ui-diff. Also, convert a "char *" to "const char *". Signed-off-by: Lukas Fleischer <[email protected]>
1 parent 750f646 commit 4e00d33

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

ui-patch.c

+17-16
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,49 @@
1111
#include "html.h"
1212
#include "ui-shared.h"
1313

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)
1516
{
1617
struct rev_info rev;
1718
struct commit *commit;
18-
unsigned char sha1[20], old_sha1[20];
19+
unsigned char new_rev_sha1[20], old_rev_sha1[20];
1920
char rev_range[2 * 40 + 3];
2021
char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range };
2122
char *patchname;
2223

23-
if (!hex)
24-
hex = ctx.qry.head;
24+
if (!new_rev)
25+
new_rev = ctx.qry.head;
2526

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);
2829
return;
2930
}
30-
commit = lookup_commit_reference(sha1);
31+
commit = lookup_commit_reference(new_rev_sha1);
3132
if (!commit) {
32-
cgit_print_error("Bad commit reference: %s", hex);
33+
cgit_print_error("Bad commit reference: %s", new_rev);
3334
return;
3435
}
3536

3637
if (old_rev) {
37-
if (get_sha1(old_rev, old_sha1)) {
38+
if (get_sha1(old_rev, old_rev_sha1)) {
3839
cgit_print_error("Bad object id: %s", old_rev);
3940
return;
4041
}
41-
if (!lookup_commit_reference(old_sha1)) {
42+
if (!lookup_commit_reference(old_rev_sha1)) {
4243
cgit_print_error("Bad commit reference: %s", old_rev);
4344
return;
4445
}
4546
} 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);
4748
} else {
48-
hashclr(old_sha1);
49+
hashclr(old_rev_sha1);
4950
}
5051

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);
5354
} 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));
5657
}
5758

5859
patchname = fmt("%s.patch", rev_range);

ui-patch.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef UI_PATCH_H
22
#define UI_PATCH_H
33

4-
extern void cgit_print_patch(char *hex, const char *old_rev, const char *prefix);
4+
extern void cgit_print_patch(const char *new_rev, const char *old_rev,
5+
const char *prefix);
56

67
#endif /* UI_PATCH_H */

0 commit comments

Comments
 (0)