From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/3] log-tree.c: small refactor in show_signature()
Date: Wed, 4 Jan 2012 14:10:57 -0800 [thread overview]
Message-ID: <1325715058-11984-3-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1325715058-11984-1-git-send-email-gitster@pobox.com>
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>
---
log-tree.c | 28 ++++++++++++++++------------
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);
--
1.7.8.2.340.gd18f0f
next prev parent reply other threads:[~2012-01-04 22:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-04 22:10 [PATCH 0/3] More on pulling signed tags Junio C Hamano
2012-01-04 22:10 ` [PATCH 1/3] verify_signed_buffer: fix stale comment Junio C Hamano
2012-01-04 22:10 ` Junio C Hamano [this message]
2012-01-04 22:10 ` [PATCH 3/3] log-tree: show mergetag in log --show-signature output Junio C Hamano
2012-01-05 0:10 ` [PATCH 0/3] More on pulling signed tags Junio C Hamano
2012-01-05 0:22 ` Junio C Hamano
2012-01-05 0:30 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1325715058-11984-3-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).