[PATCH] remove "[PATCH]" prefix from shortlog output

Subsystems: the rest

DORMANTno replies

4 messages, 3 authors, 2016-08-11 · open the first message on its own page

[PATCH] remove "[PATCH]" prefix from shortlog output

From: Nicolas Pitre <hidden>
Date: 2016-08-11 20:46:49

This doesn't convey much information in the shortlog context.
And the perl version did strip it as well.

Signed-off-by: Nicolas Pitre <redacted>

---
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index 7a2ddfe..6c4606b 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -146,6 +146,11 @@ static void insert_author_oneline(struct path_list *list,
 	while (onelinelen > 0 && isspace(oneline[onelinelen - 1]))
 		onelinelen--;
 
+	if (onelinelen > 8 && !strncasecmp(oneline, "[PATCH] ", 8)) {
+		oneline += 8;
+		onelinelen -= 8;
+	}
+
 	buffer = xmalloc(onelinelen + 1);
 	memcpy(buffer, oneline, onelinelen);

Re: [PATCH] remove "[PATCH]" prefix from shortlog output

From: Johannes Schindelin <hidden>
Date: 2016-08-11 19:28:20

Hi,

On Mon, 11 Dec 2006, Jakub Narebski wrote:
Johannes Schindelin wrote:
quoted
On Sat, 9 Dec 2006, Nicolas Pitre wrote:
quoted
This doesn't convey much information in the shortlog context.
And the perl version did strip it as well.
From the current builtin-shortlog.c:128ff:

        if (!strncmp(oneline, "[PATCH", 6)) {
                char *eob = strchr(oneline, ']');

                if (eob) {
                        while (isspace(eob[1]) && eob[1] != '\n')
                                eob++;
                        if (eob - oneline < onelinelen) {
                                onelinelen -= eob - oneline;
                                oneline = eob;
                        }
                }
        }

It tries not only to strip "[PATCH]", but also "[PATCH 0/n]" and basically 
every prefix beginning with "[PATCH" and ending in "]". I do not remember 
if I really tested that code, but it should work.
What happens if you have "[PATCH" without closing "]"? Does it work (and
doesn't crash)? Does it strip anything?
Use the source, Luke!

If "[PATCH" is there, but "]" is not, then eob will be NULL, and nothing 
happens.

Well, actually it is not completely true: the code searches for "]" in the 
_complete_ commit message (which _is_ terminated by '\0'). But only if it 
is found, _and_ it is in the first line, the substring is trimmed away.

Hth,
Dscho

Re: [PATCH] remove "[PATCH]" prefix from shortlog output

From: Jakub Narebski <hidden>
Date: 2016-08-11 19:35:47

Johannes Schindelin wrote:
On Sat, 9 Dec 2006, Nicolas Pitre wrote:
quoted
This doesn't convey much information in the shortlog context.
And the perl version did strip it as well.
From the current builtin-shortlog.c:128ff:

        if (!strncmp(oneline, "[PATCH", 6)) {
                char *eob = strchr(oneline, ']');

                if (eob) {
                        while (isspace(eob[1]) && eob[1] != '\n')
                                eob++;
                        if (eob - oneline < onelinelen) {
                                onelinelen -= eob - oneline;
                                oneline = eob;
                        }
                }
        }

It tries not only to strip "[PATCH]", but also "[PATCH 0/n]" and basically 
every prefix beginning with "[PATCH" and ending in "]". I do not remember 
if I really tested that code, but it should work.
What happens if you have "[PATCH" without closing "]"? Does it work (and
doesn't crash)? Does it strip anything?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

Re: [PATCH] remove "[PATCH]" prefix from shortlog output

From: Johannes Schindelin <hidden>
Date: 2016-08-11 20:07:11

Hi,

On Sat, 9 Dec 2006, Nicolas Pitre wrote:
This doesn't convey much information in the shortlog context.
And the perl version did strip it as well.
From the current builtin-shortlog.c:128ff:

        if (!strncmp(oneline, "[PATCH", 6)) {
                char *eob = strchr(oneline, ']');

                if (eob) {
                        while (isspace(eob[1]) && eob[1] != '\n')
                                eob++;
                        if (eob - oneline < onelinelen) {
                                onelinelen -= eob - oneline;
                                oneline = eob;
                        }
                }
        }

It tries not only to strip "[PATCH]", but also "[PATCH 0/n]" and basically 
every prefix beginning with "[PATCH" and ending in "]". I do not remember 
if I really tested that code, but it should work.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help