summaryrefslogtreecommitdiff
path: root/log-tree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-01-04 21:48:45 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-01-05 21:02:26 (GMT)
commitc6b3ec41e2efdd9e05118c2e99ad70f0e0629873 (patch)
tree098a579eca704eb3761f7b39d3196d6bd55637ef /log-tree.c
parentc871a1d17b8433d98df59b03da5538f10c4ae52c (diff)
downloadgit-c6b3ec41e2efdd9e05118c2e99ad70f0e0629873.zip
git-c6b3ec41e2efdd9e05118c2e99ad70f0e0629873.tar.gz
git-c6b3ec41e2efdd9e05118c2e99ad70f0e0629873.tar.bz2
log-tree.c: small refactor in show_signature()
The next patch needs to show the result of signature verification on a mergetag extended header in a way similar to how embedded signature for the commit object itself is shown. Separate out the logic to go through the message lines and show them in the "error" color (highlighted) or the "correct" color (dim). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'log-tree.c')
-rw-r--r--log-tree.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/log-tree.c b/log-tree.c
index 142ba51..005c5a5 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -404,13 +404,27 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
*extra_headers_p = extra_headers;
}
+static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
+{
+ const char *color, *reset, *eol;
+
+ color = diff_get_color_opt(&opt->diffopt,
+ status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
+ reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
+ while (*bol) {
+ eol = strchrnul(bol, '\n');
+ printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
+ *eol ? "\n" : "");
+ bol = (*eol) ? (eol + 1) : eol;
+ }
+}
+
static void show_signature(struct rev_info *opt, struct commit *commit)
{
struct strbuf payload = STRBUF_INIT;
struct strbuf signature = STRBUF_INIT;
struct strbuf gpg_output = STRBUF_INIT;
int status;
- const char *color, *reset, *bol, *eol;
if (parse_signed_commit(commit->object.sha1, &payload, &signature) <= 0)
goto out;
@@ -421,17 +435,7 @@ static void show_signature(struct rev_info *opt, struct commit *commit)
if (status && !gpg_output.len)
strbuf_addstr(&gpg_output, "No signature\n");
- color = diff_get_color_opt(&opt->diffopt,
- status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
- reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
-
- bol = gpg_output.buf;
- while (*bol) {
- eol = strchrnul(bol, '\n');
- printf("%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
- *eol ? "\n" : "");
- bol = (*eol) ? (eol + 1) : eol;
- }
+ show_sig_lines(opt, status, gpg_output.buf);
out:
strbuf_release(&gpg_output);