diff options
| author | 2013-08-21 01:56:15 (JST) | |
|---|---|---|
| committer | 2013-08-21 02:55:54 (JST) | |
| commit | 4e00d338b07245829adf2446a05fe4925b691092 (patch) | |
| tree | 2f0a96954a7eeae502cc9d697d335866fc22e6d5 | |
| parent | 750f6462c9e1e20e87d2bce5ca2e7fd10e0d1ba6 (diff) | |
| download | cgit-4e00d338b07245829adf2446a05fe4925b691092.zip cgit-4e00d338b07245829adf2446a05fe4925b691092.tar.gz | |
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 <cgit@cryptocrack.de>
| -rw-r--r-- | ui-patch.c | 33 | ||||
| -rw-r--r-- | ui-patch.h | 3 |
2 files changed, 19 insertions, 17 deletions
| @@ -11,48 +11,49 @@ | |||
| 11 | #include "html.h" | 11 | #include "html.h" |
| 12 | #include "ui-shared.h" | 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 | struct rev_info rev; | 17 | struct rev_info rev; |
| 17 | struct commit *commit; | 18 | struct commit *commit; |
| 18 | unsigned char sha1[20], old_sha1[20]; | 19 | unsigned char new_rev_sha1[20], old_rev_sha1[20]; |
| 19 | char rev_range[2 * 40 + 3]; | 20 | char rev_range[2 * 40 + 3]; |
| 20 | char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range }; | 21 | char *rev_argv[] = { NULL, "--reverse", "--format=email", rev_range }; |
| 21 | char *patchname; | 22 | char *patchname; |
| 22 | 23 | ||
| 23 | if (!hex) | 24 | if (!new_rev) |
| 24 | hex = ctx.qry.head; | 25 | new_rev = ctx.qry.head; |
| 25 | 26 | ||
| 26 | if (get_sha1(hex, sha1)) { | 27 | if (get_sha1(new_rev, new_rev_sha1)) { |
| 27 | cgit_print_error("Bad object id: %s", hex); | 28 | cgit_print_error("Bad object id: %s", new_rev); |
| 28 | return; | 29 | return; |
| 29 | } | 30 | } |
| 30 | commit = lookup_commit_reference(sha1); | 31 | commit = lookup_commit_reference(new_rev_sha1); |
| 31 | if (!commit) { | 32 | if (!commit) { |
| 32 | cgit_print_error("Bad commit reference: %s", hex); | 33 | cgit_print_error("Bad commit reference: %s", new_rev); |
| 33 | return; | 34 | return; |
| 34 | } | 35 | } |
| 35 | 36 | ||
| 36 | if (old_rev) { | 37 | if (old_rev) { |
| 37 | if (get_sha1(old_rev, old_sha1)) { | 38 | if (get_sha1(old_rev, old_rev_sha1)) { |
| 38 | cgit_print_error("Bad object id: %s", old_rev); | 39 | cgit_print_error("Bad object id: %s", old_rev); |
| 39 | return; | 40 | return; |
| 40 | } | 41 | } |
| 41 | if (!lookup_commit_reference(old_sha1)) { | 42 | if (!lookup_commit_reference(old_rev_sha1)) { |
| 42 | cgit_print_error("Bad commit reference: %s", old_rev); | 43 | cgit_print_error("Bad commit reference: %s", old_rev); |
| 43 | return; | 44 | return; |
| 44 | } | 45 | } |
| 45 | } else if (commit->parents && commit->parents->item) { | 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 | } else { | 48 | } else { |
| 48 | hashclr(old_sha1); | 49 | hashclr(old_rev_sha1); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | if (is_null_sha1(old_sha1)) { | 52 | if (is_null_sha1(old_rev_sha1)) { |
| 52 | memcpy(rev_range, sha1_to_hex(sha1), 41); | 53 | memcpy(rev_range, sha1_to_hex(new_rev_sha1), 41); |
| 53 | } else { | 54 | } else { |
| 54 | sprintf(rev_range, "%s..%s", sha1_to_hex(old_sha1), | 55 | sprintf(rev_range, "%s..%s", sha1_to_hex(old_rev_sha1), |
| 55 | sha1_to_hex(sha1)); | 56 | sha1_to_hex(new_rev_sha1)); |
| 56 | } | 57 | } |
| 57 | 58 | ||
| 58 | patchname = fmt("%s.patch", rev_range); | 59 | patchname = fmt("%s.patch", rev_range); |
| @@ -1,6 +1,7 @@ | |||
| 1 | #ifndef UI_PATCH_H | 1 | #ifndef UI_PATCH_H |
| 2 | #define UI_PATCH_H | 2 | #define UI_PATCH_H |
| 3 | 3 | ||
| 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); | ||
| 5 | 6 | ||
| 6 | #endif /* UI_PATCH_H */ | 7 | #endif /* UI_PATCH_H */ |
