From: Jeff King <peff@peff.net>
To: Dietmar Winkler <dietmarw@gmx.de>
Cc: git@vger.kernel.org
Subject: [PATCH 1/2] pretty.c: give format_person_part the whole placeholder
Date: Sat, 5 Mar 2011 14:51:56 -0500 [thread overview]
Message-ID: <20110305195156.GA32095@sigill.intra.peff.net> (raw)
In-Reply-To: <20110305195020.GA3089@sigill.intra.peff.net>
Until now it only got to see the next character. Giving it
the whole string will make it possible to add longer
placeholders in a future patch.
Signed-off-by: Jeff King <peff@peff.net>
---
I split this out because the patch ends up so noisy.
pretty.c | 20 ++++++++++----------
1 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/pretty.c b/pretty.c
index 8549934..00bcf83 100644
--- a/pretty.c
+++ b/pretty.c
@@ -440,7 +440,7 @@ static int mailmap_name(char *email, int email_len, char *name, int name_len)
return mail_map->nr && map_user(mail_map, email, email_len, name, name_len);
}
-static size_t format_person_part(struct strbuf *sb, char part,
+static size_t format_person_part(struct strbuf *sb, const char *part,
const char *msg, int len, enum date_mode dmode)
{
/* currently all placeholders have same length */
@@ -477,7 +477,7 @@ static size_t format_person_part(struct strbuf *sb, char part,
goto skip;
end = mail_end-msg;
- if (part == 'N' || part == 'E') { /* mailmap lookup */
+ if (*part == 'N' || *part == 'E') { /* mailmap lookup */
strlcpy(person_name, name_start, name_end-name_start+1);
strlcpy(person_mail, mail_start, mail_end-mail_start+1);
mailmap_name(person_mail, sizeof(person_mail), person_name, sizeof(person_name));
@@ -486,11 +486,11 @@ static size_t format_person_part(struct strbuf *sb, char part,
mail_start = person_mail;
mail_end = mail_start + strlen(person_mail);
}
- if (part == 'n' || part == 'N') { /* name */
+ if (*part == 'n' || *part == 'N') { /* name */
strbuf_add(sb, name_start, name_end-name_start);
return placeholder_len;
}
- if (part == 'e' || part == 'E') { /* email */
+ if (*part == 'e' || *part == 'E') { /* email */
strbuf_add(sb, mail_start, mail_end-mail_start);
return placeholder_len;
}
@@ -504,7 +504,7 @@ static size_t format_person_part(struct strbuf *sb, char part,
if (msg + start == ep)
goto skip;
- if (part == 't') { /* date, UNIX timestamp */
+ if (*part == 't') { /* date, UNIX timestamp */
strbuf_add(sb, msg + start, ep - (msg + start));
return placeholder_len;
}
@@ -518,7 +518,7 @@ static size_t format_person_part(struct strbuf *sb, char part,
tz = -tz;
}
- switch (part) {
+ switch (*part) {
case 'd': /* date */
strbuf_addstr(sb, show_date(date, tz, dmode));
return placeholder_len;
@@ -538,8 +538,8 @@ skip:
* bogus commit, 'sb' cannot be updated, but we still need to
* compute a valid return value.
*/
- if (part == 'n' || part == 'e' || part == 't' || part == 'd'
- || part == 'D' || part == 'r' || part == 'i')
+ if (*part == 'n' || *part == 'e' || *part == 't' || *part == 'd'
+ || *part == 'D' || *part == 'r' || *part == 'i')
return placeholder_len;
return 0; /* unknown placeholder */
@@ -899,11 +899,11 @@ static size_t format_commit_one(struct strbuf *sb, const char *placeholder,
switch (placeholder[0]) {
case 'a': /* author ... */
- return format_person_part(sb, placeholder[1],
+ return format_person_part(sb, placeholder + 1,
msg + c->author.off, c->author.len,
c->pretty_ctx->date_mode);
case 'c': /* committer ... */
- return format_person_part(sb, placeholder[1],
+ return format_person_part(sb, placeholder + 1,
msg + c->committer.off, c->committer.len,
c->pretty_ctx->date_mode);
case 'e': /* encoding */
--
1.7.4.rc1.24.g38985d
next prev parent reply other threads:[~2011-03-05 19:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-03 9:30 [Bug] %[a|c]d placeholder does not respect --date= option in combination with git archive Dietmar Winkler
2011-03-03 15:10 ` Jeff King
2011-03-04 10:10 ` Dietmar Winkler
2011-03-05 19:50 ` Jeff King
2011-03-05 19:51 ` Jeff King [this message]
2011-03-05 20:00 ` [PATCH 2/2] pretty.c: allow date formats in user format strings Jeff King
[not found] ` <AANLkTinH8zwX2sbd5bpk=x4R3zOAg3Dc92Fbspfdv03T@mail.gmail.com>
2011-03-06 21:54 ` Fwd: " Will Palmer
2011-03-07 16:17 ` Jeff King
2011-03-07 17:28 ` Will Palmer
2011-03-07 18:50 ` Will Palmer
2011-03-07 19:26 ` Jeff King
2011-03-08 8:29 ` Will Palmer
2011-03-09 21:06 ` Junio C Hamano
2011-03-10 22:31 ` Jeff King
2011-03-11 8:33 ` Dietmar Winkler
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=20110305195156.GA32095@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=dietmarw@gmx.de \
--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).