[PATCH 1/2] pretty.c: give format_person_part the whole placeholder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]