Thread (30 messages) flat view 30 messages, 7 authors, 2021-09-24

Re: [PATCH 1/5] grep: stop modifying buffer in strip_timestamp

From: Jeff King <hidden>
Date: 2021-09-21 14:24:37

On Tue, Sep 21, 2021 at 09:37:23AM +0200, René Scharfe wrote:
quoted
@@ -965,9 +953,12 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
 		bol += len;
 		switch (p->field) {
 		case GREP_HEADER_AUTHOR:
-		case GREP_HEADER_COMMITTER:
-			strip_timestamp(bol, &eol);
+		case GREP_HEADER_COMMITTER: {
+			char *em = memrchr(bol, '>', eol - bol);
+			if (em)
+				eol = em + 1;
The old code documents the intent via the function name.  The new one
goes into the nitty-gritty without further explanation, which I find
harder to read.
Agreed. I do think the conversion is functionally correct, but it
doesn't strike me as worth the change.

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