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

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

From
Tanay Abhra <tanayabh@gmail.com>
Date
Mar 4, 2014, 17:31 UTC
Message-ID
<loom.20140304T182823-503@post.gmane.org>
In-Reply-To
<1393948445-24689-1-git-send-email-karthik.188@gmail.com>
Karthik Nayak <karthik.188 <at> gmail.com> writes:
Show 23 quoted lines
> 
> In record_author_date() :
> Replace "buf + strlen(author )" by skip_prefix(), which is
> saved in a new "const char" variable "indent_line".
> 
> In parse_signed_commit() :
> Replace "line + gpg_sig_header_len" by skip_prefix(), which
> is saved in a new "const char" variable "indent_line".
> 
> In parse_gpg_output() :
> Replace "buf + strlen(sigcheck_gpg_status[i].check + 1)" by
> skip_prefix(), which is saved in already available
> variable "found".
> 
> Signed-off-by: Karthik Nayak <karthik.188 <at> gmail.com>
> ---
>  commit.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/commit.c b/commit.c
> index 6bf4fe0..71a03e3 100644
> --- a/commit.c
> +++ b/commit.c
>  <at>  <at>  -1098,6 +1100,7  <at>  <at>  int parse_signed_commit(const
unsigned char *sha1,
Show 8 quoted lines
>  	char *buffer = read_sha1_file(sha1, &type, &size);
>  	int in_signature, saw_signature = -1;
>  	char *line, *tail;
> +	const char *indent_line;
> 
>  	if (!buffer || type != OBJ_COMMIT)
>  		goto cleanup;
>  <at>  <at>  -1111,11 +1114,11  <at>  <at>  int parse_signed_commit(const
unsigned char *sha1,
Show 14 quoted lines
>  		char *next = memchr(line, '\n', tail - line);
> 
>  		next = next ? next + 1 : tail;
> +		indent_line = skip_prefix(line, gpg_sig_header);
>  		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 (indent_line && indent_line[1] == ' ')
> +			sig = indent_line + 2;
>  		if (sig) {
>  			strbuf_add(signature, sig, next - sig);
>  			saw_signature = 1;
Hi,

I was attempting the same microproject so I thought I would share some points that were told to me earlier .The mail subject should have a increasing order of submission numbers for each revision(for example here it should be [PATCH v2]).

Also write the superfluous stuff which you have written in the bottom after ---(the three dashes after the signed off statement) .

In the parse_signed_commit() function, gpg_sig_header_len and gpg_sig_header variables are precomputed outside of the function, and also Junio said to prefer starts_with(), whenever skip_prefix() advantages are not so important in the context.So the replace may not be so advantageous ,I may be wrong in this case.

 

Cheers, Tanay Abhra.

Previous: Karthik NayakNext: karthik nayak
Message 2 of 7 in “commit.c: Replace starts_with() with skip_prefix()”
  1. [PATCH] commit.c: Replace starts_with() with skip_prefix()Karthik Nayak, Mar 4, 2014
  2. Tanay AbhraMar 4, 2014
  3. karthik nayakMar 4, 2014
  4. Eric SunshineMar 4, 2014
  5. Eric SunshineMar 4, 2014
  6. Eric SunshineMar 4, 2014
  7. Eric SunshineMar 5, 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.