From: Jeff King <peff@peff.net>
To: nathan.panike@gmail.com
Cc: git@vger.kernel.org
Subject: [PATCH 1/2] pretty: refactor --format "magic" placeholders
Date: Fri, 23 Dec 2011 05:35:59 -0500 [thread overview]
Message-ID: <20111223103558.GA28036@sigill.intra.peff.net> (raw)
In-Reply-To: <20111223100957.GA1247@sigill.intra.peff.net>
Instead of assuming each magic token is a single character,
let's handle arbitrary-sized magic.
Signed-off-by: Jeff King <peff@peff.net>
---
pretty.c | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/pretty.c b/pretty.c
index 230fe1c..7b4d098 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1018,6 +1018,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
void *context)
{
int consumed;
+ int magic_len = 0;
size_t orig_len;
enum {
NO_MAGIC,
@@ -1039,13 +1040,13 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
default:
break;
}
- if (magic != NO_MAGIC)
+ if (magic != NO_MAGIC) {
+ magic_len++;
placeholder++;
+ }
orig_len = sb->len;
consumed = format_commit_one(sb, placeholder, context);
- if (magic == NO_MAGIC)
- return consumed;
if ((orig_len == sb->len) && magic == DEL_LF_BEFORE_EMPTY) {
while (sb->len && sb->buf[sb->len - 1] == '\n')
@@ -1056,7 +1057,7 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
else if (magic == ADD_SP_BEFORE_NON_EMPTY)
strbuf_insert(sb, orig_len, " ", 1);
}
- return consumed + 1;
+ return consumed + magic_len;
}
static size_t userformat_want_item(struct strbuf *sb, const char *placeholder,
--
1.7.8.1.3.gba11d
next prev parent reply other threads:[~2011-12-23 10:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-20 22:07 [PATCH] Specify a precision for the length of a subject string Nathan W. Panike
2011-12-20 22:15 ` Thomas Rast
2011-12-20 22:50 ` Nathan Panike
2011-12-21 4:38 ` Jeff King
2011-12-21 14:51 ` Nathan Panike
2011-12-23 10:09 ` Jeff King
2011-12-23 10:35 ` Jeff King
2011-12-23 20:58 ` Junio C Hamano
2011-12-23 23:02 ` Jeff King
2011-12-23 23:03 ` Jeff King
2011-12-23 10:35 ` Jeff King [this message]
2011-12-23 10:36 ` [PATCH 2/2] pretty: allow "max-size" magic for all placeholders Jeff King
2011-12-21 11:26 ` [PATCH] Specify a precision for the length of a subject string Andreas Schwab
2011-12-21 14:53 ` Nathan Panike
2011-12-23 9:41 ` Miles Bader
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=20111223103558.GA28036@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=nathan.panike@gmail.com \
/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).