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

From:
Omar Polo <op@omarpolo.com>
Subject:
needless id serialization in match_logmsg
To:
gameoftrees@openbsd.org
Date:
Sat, 11 Jun 2022 11:19:37 +0200

Download raw body.

Thread
reading the thread about searching/filtering by commit author, I took a
look at got.c' match_logmsg and spotted this (apparently) needless
serialization of the commit id.

it's there since match_logmsg was introduced in 6841bf1 by kn@.  the log
message says it was copied from tog' match_commit, but tog version also
matches on the author, committer and commit id (hence why it needs the
id string.)


P.S.: somehow syncing the two functions maybe it's not a bad idea.  I'd
like if it matched also the committer/author as hinted by stps@ in the
other thread, but I'm not that sure matching commits ids is a useful
feature.

diff 3ef807eedd4fec23cf457ea7cd55bc01407d57b9 /home/op/w/got
blob - 28ba9a46f202c773426d431a909c5dec6304d3ca
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -3736,14 +3736,10 @@ match_logmsg(int *have_match, struct got_object_id *id
 {
 	const struct got_error *err = NULL;
 	regmatch_t regmatch;
-	char *id_str = NULL, *logmsg = NULL;
+	char *logmsg = NULL;
 
 	*have_match = 0;
 
-	err = got_object_id_str(&id_str, id);
-	if (err)
-		return err;
-
 	err = got_object_commit_get_logmsg(&logmsg, commit);
 	if (err)
 		goto done;
@@ -3751,7 +3747,6 @@ match_logmsg(int *have_match, struct got_object_id *id
 	if (regexec(regex, logmsg, 1, &regmatch, 0) == 0)
 		*have_match = 1;
 done:
-	free(id_str);
 	free(logmsg);
 	return err;
 }