"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: abort commit if merged log messages are left as-is
To:
Christian Weisgerber <naddy@mips.inka.de>, gameoftrees@openbsd.org
Date:
Fri, 10 Feb 2023 22:07:42 +1100

Download raw body.

Thread
On 23-02-10 11:38AM, Stefan Sperling wrote:
> On Fri, Feb 10, 2023 at 08:59:29PM +1100, Mark Jamsek wrote:
> > Below diff is the same except with your improvement:
> 
> Thanks, ok.
> 
> In a follow-up commit we could garbage-collect the strip_comments
> parameter from read_logmsg() because it is now always 1.

Yes, of course! Here it is:

diff /home/mark/src/got
commit - 50da8693beac27440a7df88952690b12d422bb13
path + /home/mark/src/got
blob - 4a0cd57f859bca5045a0003d40445f08adc26657
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -389,8 +389,7 @@ read_logmsg(char **logmsg, size_t *len, FILE *fp, size
 }
 
 static const struct got_error *
-read_logmsg(char **logmsg, size_t *len, FILE *fp, size_t filesize,
-    int strip_comments)
+read_logmsg(char **logmsg, size_t *len, FILE *fp, size_t filesize)
 {
 	const struct got_error *err = NULL;
 	char *line = NULL;
@@ -408,8 +407,7 @@ read_logmsg(char **logmsg, size_t *len, FILE *fp, size
 	(*logmsg)[0] = '\0';
 
 	while (getline(&line, &linesize, fp) != -1) {
-		if ((strip_comments && line[0] == '#') ||
-		    (*len == 0 && line[0] == '\n'))
+		if (line[0] == '#' || (*len == 0 && line[0] == '\n'))
 			continue; /* remove comments and leading empty lines */
 		*len = strlcat(*logmsg, line, filesize + 1);
 		if (*len >= filesize + 1) {
@@ -468,7 +466,7 @@ edit_logmsg(char **logmsg, const char *editor, const c
 	}
 
 	/* strip comments and leading/trailing newlines */
-	err = read_logmsg(logmsg, &logmsg_len, fp, st2.st_size, 1);
+	err = read_logmsg(logmsg, &logmsg_len, fp, st2.st_size);
 	if (err)
 		goto done;
 	if (logmsg_len == 0) {

-- 
Mark Jamsek <fnc.bsdbox.org|got.bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68