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

Re: [PATCH v3] commit.c: Replace starts_with() with skip_prefix()

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 6, 2014, 19:42 UTC
Message-ID
<xmqqfvmvxgf5.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1394125521-9341-1-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 18 quoted lines
> @@ -1098,6 +1099,7 @@ int parse_signed_commit(const unsigned char *sha1,
>  	char *buffer = read_sha1_file(sha1, &type, &size);
>  	int in_signature, saw_signature = -1;
>  	char *line, *tail;
> +	const char *gpg_sig;
>  
>  	if (!buffer || type != OBJ_COMMIT)
>  		goto cleanup;
> @@ -1113,9 +1115,9 @@ int parse_signed_commit(const unsigned char *sha1,
>  		next = next ? next + 1 : tail;
>  		if (in_signature && line[0] == ' ')
>  			sig = line + 1;
> -		else if (starts_with(line, gpg_sig_header) &&
> -			 line[gpg_sig_header_len] == ' ')
> -			sig = line + gpg_sig_header_len + 1;
> +		else if ((gpg_sig = skip_prefix(line, gpg_sig_header))
> +			  && gpg_sig[0] == ' ')
> +			sig = gpg_sig + 1;

I am not sure if this hunk is a great improvement, as we know the length of what we are skipping in the gpg_sig_header_len constant that is used throughout this file.

Previous: Junio C HamanoNext: Eric Sunshine
Message 3 of 7 in “commit.c: Replace starts_with() with skip_prefix()”
  1. commit.c: Replace starts_with() with skip_prefix()Karthik Nayak, Mar 6, 2014
  2. Junio C HamanoMar 6, 2014
  3. Junio C HamanoMar 6, 2014
  4. Eric SunshineMar 7, 2014
  5. karthik nayakMar 7, 2014
  6. Eric SunshineMar 9, 2014
  7. karthik nayakMar 9, 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.