[PATCH 1/2] shortlog: refactor insert_one_record()

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

 



This just splits insert_one_record() into one part which assumes that
the key is an email ident of the form "A U Thor <author@xxxxxxxxxxx>"
(that needs to respect .mailmap) and a second part which does not.

Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx>
---
 builtin-shortlog.c |   81 ++++++++++++++++++++++++++++-----------------------
 1 files changed, 44 insertions(+), 37 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 6a3812e..a684422 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -32,19 +32,57 @@ static int compare_by_number(const void *a1, const void *a2)
 const char *format_subject(struct strbuf *sb, const char *msg,
 			   const char *line_separator);
 
-static void insert_one_record(struct shortlog *log,
-			      const char *author,
-			      const char *oneline)
+static void insert_one_record1(struct shortlog *log,
+		const char *name, const char *oneline)
 {
 	const char *dot3 = log->common_repo_prefix;
 	char *buffer, *p;
 	struct string_list_item *item;
+	const char *eol;
+	struct strbuf subject = STRBUF_INIT;
+
+	item = string_list_insert(name, &log->list);
+	if (item->util == NULL)
+		item->util = xcalloc(1, sizeof(struct string_list));
+
+	/* Skip any leading whitespace, including any blank lines. */
+	while (*oneline && isspace(*oneline))
+		oneline++;
+	eol = strchr(oneline, '\n');
+	if (!eol)
+		eol = oneline + strlen(oneline);
+	if (!prefixcmp(oneline, "[PATCH")) {
+		char *eob = strchr(oneline, ']');
+		if (eob && (!eol || eob < eol))
+			oneline = eob + 1;
+	}
+	while (*oneline && isspace(*oneline) && *oneline != '\n')
+		oneline++;
+	format_subject(&subject, oneline, " ");
+	buffer = strbuf_detach(&subject, NULL);
+
+	if (dot3) {
+		int dot3len = strlen(dot3);
+		if (dot3len > 5) {
+			while ((p = strstr(buffer, dot3)) != NULL) {
+				int taillen = strlen(p) - dot3len;
+				memcpy(p, "/.../", 5);
+				memmove(p + 5, p + dot3len, taillen + 1);
+			}
+		}
+	}
+
+	string_list_append(buffer, item->util);
+}
+
+static void insert_one_record(struct shortlog *log,
+			      const char *author,
+			      const char *oneline)
+{
 	char namebuf[1024];
 	char emailbuf[1024];
 	size_t len;
-	const char *eol;
 	const char *boemail, *eoemail;
-	struct strbuf subject = STRBUF_INIT;
 
 	boemail = strchr(author, '<');
 	if (!boemail)
@@ -84,38 +122,7 @@ static void insert_one_record(struct shortlog *log,
 		snprintf(namebuf + len, room, " <%.*s>", maillen, emailbuf);
 	}
 
-	item = string_list_insert(namebuf, &log->list);
-	if (item->util == NULL)
-		item->util = xcalloc(1, sizeof(struct string_list));
-
-	/* Skip any leading whitespace, including any blank lines. */
-	while (*oneline && isspace(*oneline))
-		oneline++;
-	eol = strchr(oneline, '\n');
-	if (!eol)
-		eol = oneline + strlen(oneline);
-	if (!prefixcmp(oneline, "[PATCH")) {
-		char *eob = strchr(oneline, ']');
-		if (eob && (!eol || eob < eol))
-			oneline = eob + 1;
-	}
-	while (*oneline && isspace(*oneline) && *oneline != '\n')
-		oneline++;
-	format_subject(&subject, oneline, " ");
-	buffer = strbuf_detach(&subject, NULL);
-
-	if (dot3) {
-		int dot3len = strlen(dot3);
-		if (dot3len > 5) {
-			while ((p = strstr(buffer, dot3)) != NULL) {
-				int taillen = strlen(p) - dot3len;
-				memcpy(p, "/.../", 5);
-				memmove(p + 5, p + dot3len, taillen + 1);
-			}
-		}
-	}
-
-	string_list_append(buffer, item->util);
+	insert_one_record1(log, namebuf, oneline);
 }
 
 static void read_from_stdin(struct shortlog *log)
-- 
1.6.3.284.g6fecc


--
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]