git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH V2] commit.c: Use skip_prefix() instead of starts_with()

From
Max Horn <max@quendi.de>
Date
Mar 3, 2014, 22:59 UTC
Message-ID
<176A3D83-AFFB-4EF4-A1CB-3A953F692166@quendi.de>
In-Reply-To
<xmqqiorvoyoo.fsf@gitster.dls.corp.google.com>
On 03.03.2014, at 20:43, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Tanay Abhra <tanayabh@gmail.com> writes:
> 
>> @@ -1193,9 +1194,9 @@ static void parse_gpg_output(struct signature_check *sigc)
>> 	for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
>> 		const char *found, *next;
>> 
>> -		if (starts_with(buf, sigcheck_gpg_status[i].check + 1)) {
>> +		if (found = skip_prefix(buf, sigcheck_gpg_status[i].check + 1)) {
>> 			/* At the very beginning of the buffer */
>> -			found = buf + strlen(sigcheck_gpg_status[i].check + 1);
>> +			;
>> 		} else {
>> 			found = strstr(buf, sigcheck_gpg_status[i].check);
>> 			if (!found)
> 
> This hunk looks good.  It can be a separate patch but they are both
> minor changes so it is OK to have it in a single patch.
Hm, but that hunk also introduces an assignment in a conditional, and introduces an empty block. Maybe like this?
diff --git a/commit.c b/commit.c
index 6bf4fe0..0ee0725 100644
--- a/commit.c
+++ b/commit.c
@@ -1193,10 +1193,8 @@ static void parse_gpg_output(struct signature_check *sigc)
        for (i = 0; i < ARRAY_SIZE(sigcheck_gpg_status); i++) {
                const char *found, *next;

-               if (starts_with(buf, sigcheck_gpg_status[i].check + 1)) {
-                       /* At the very beginning of the buffer */
-                       found = buf + strlen(sigcheck_gpg_status[i].check + 1);
-               } else {
+               found = skip_prefix(buf, sigcheck_gpg_status[i].check + 1);
+               if (!found) {
                        found = strstr(buf, sigcheck_gpg_status[i].check);
                        if (!found)
                                continue;
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “commit.c: Use skip_prefix() instead of starts_with()”
  1. commit.c: Use skip_prefix() instead of starts_with()Tanay Abhra, Mar 3, 2014
  2. Junio C HamanoMar 3, 2014
  3. Max HornMar 3, 2014
  4. Junio C HamanoMar 3, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.