From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Subject: [PATCH 1/3] pretty: make some commit-parsing helpers more public
Date: Mon, 24 Sep 2012 20:24:17 -0400 [thread overview]
Message-ID: <20120925002417.GA19605@sigill.intra.peff.net> (raw)
In-Reply-To: <20120925002325.GA19560@sigill.intra.peff.net>
This is a quick hack to make these functions available for
the lua code. It would be way cleaner to move all of the
incremental parsing bits to format-commit.[ch] and clean up
the names (e.g., "struct chunk" is not nearly descriptive
enough for a global).
Signed-off-by: Jeff King <peff@peff.net>
---
commit.h | 36 ++++++++++++++++++++++++++++++++++++
pretty.c | 38 ++------------------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
diff --git a/commit.h b/commit.h
index 9f21313..71cd4af 100644
--- a/commit.h
+++ b/commit.h
@@ -126,6 +126,42 @@ void pp_remainder(const struct pretty_print_context *pp,
struct strbuf *sb,
int indent);
+struct chunk {
+ size_t off;
+ size_t len;
+};
+
+struct format_commit_context {
+ const struct commit *commit;
+ const struct pretty_print_context *pretty_ctx;
+ unsigned commit_header_parsed:1;
+ unsigned commit_message_parsed:1;
+ unsigned commit_signature_parsed:1;
+ struct {
+ char *gpg_output;
+ char good_bad;
+ char *signer;
+ } signature;
+ char *message;
+ size_t width, indent1, indent2;
+
+ /* These offsets are relative to the start of the commit message. */
+ struct chunk author;
+ struct chunk committer;
+ struct chunk encoding;
+ size_t message_off;
+ size_t subject_off;
+ size_t body_off;
+
+ /* The following ones are relative to the result struct strbuf. */
+ struct chunk abbrev_commit_hash;
+ struct chunk abbrev_tree_hash;
+ struct chunk abbrev_parent_hashes;
+ size_t wrap_start;
+};
+
+void parse_commit_header(struct format_commit_context *);
+void parse_commit_message(struct format_commit_context *);
/** Removes the first commit from a list sorted by date, and adds all
* of its parents.
diff --git a/pretty.c b/pretty.c
index 8b1ea9f..0d4eb3d 100644
--- a/pretty.c
+++ b/pretty.c
@@ -612,40 +612,6 @@ skip:
return 0; /* unknown placeholder */
}
-struct chunk {
- size_t off;
- size_t len;
-};
-
-struct format_commit_context {
- const struct commit *commit;
- const struct pretty_print_context *pretty_ctx;
- unsigned commit_header_parsed:1;
- unsigned commit_message_parsed:1;
- unsigned commit_signature_parsed:1;
- struct {
- char *gpg_output;
- char good_bad;
- char *signer;
- } signature;
- char *message;
- size_t width, indent1, indent2;
-
- /* These offsets are relative to the start of the commit message. */
- struct chunk author;
- struct chunk committer;
- struct chunk encoding;
- size_t message_off;
- size_t subject_off;
- size_t body_off;
-
- /* The following ones are relative to the result struct strbuf. */
- struct chunk abbrev_commit_hash;
- struct chunk abbrev_tree_hash;
- struct chunk abbrev_parent_hashes;
- size_t wrap_start;
-};
-
static int add_again(struct strbuf *sb, struct chunk *chunk)
{
if (chunk->len) {
@@ -663,7 +629,7 @@ static int add_again(struct strbuf *sb, struct chunk *chunk)
return 0;
}
-static void parse_commit_header(struct format_commit_context *context)
+void parse_commit_header(struct format_commit_context *context)
{
const char *msg = context->message;
int i;
@@ -749,7 +715,7 @@ const char *format_subject(struct strbuf *sb, const char *msg,
return msg;
}
-static void parse_commit_message(struct format_commit_context *c)
+void parse_commit_message(struct format_commit_context *c)
{
const char *msg = c->message + c->message_off;
const char *start = c->message;
--
1.7.12.1.10.g6537447
next prev parent reply other threads:[~2012-09-25 0:24 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-25 0:23 [RFC/PATCH 0/3] git log --pretty=lua Jeff King
2012-09-25 0:24 ` Jeff King [this message]
2012-09-25 0:25 ` [PATCH 2/3] add basic lua infrastructure Jeff King
2012-09-25 1:55 ` Nguyen Thai Ngoc Duy
2012-09-25 4:53 ` Jeff King
2012-09-25 3:21 ` Robin H. Johnson
2012-09-25 3:42 ` Jeff King
2012-09-25 21:18 ` Junio C Hamano
2012-09-25 0:25 ` [PATCH 3/3] add a "lua" pretty format Jeff King
2012-10-06 17:33 ` Jeff King
2012-09-25 11:22 ` [RFC/PATCH 0/3] git log --pretty=lua Nguyen Thai Ngoc Duy
2012-09-25 13:49 ` Stephen Bash
2012-09-25 15:19 ` Matthieu Moy
2012-09-25 16:40 ` Junio C Hamano
2012-09-30 4:31 ` Nguyen Thai Ngoc Duy
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120925002417.GA19605@sigill.intra.peff.net \
--to=peff@peff.net \
--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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).