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

Re: [PATCH] GSoC 2014 Microproject 1 rewrite skip_prefix() as loop

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
Feb 27, 2014, 11:32 UTC
Message-ID
<530F2238.4090303@alum.mit.edu>
In-Reply-To
<1393433195.4629.4.camel@dj-pc>
On 02/26/2014 05:46 PM, Faiz Kothari wrote:
Show 5 quoted lines
> I am Faiz Kothari, I am a GSoC aspirant and want to contribute to git.
> I am submitting the patch in reponse to Microproject 1,
> rewrite git-compat-util.h:skip_prefix() as a loop.
> 
> Signed-off-by: Faiz Kothari <faiz.off93@gmail.com>

The subject of your email plus the part above the "---" line will be taken directly to be used as the commit message. So it should not include information that is inappropriate for a commit message.

You can put such information directly below the "---" line.
Please also see my comments below.
Show 13 quoted lines
> ---
>  git-compat-util.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/git-compat-util.h b/git-compat-util.h
> index cbd86c3..bb2582a 100644
> --- a/git-compat-util.h
> +++ b/git-compat-util.h
> @@ -357,8 +357,11 @@ extern int suffixcmp(const char *str, const char
> *suffix);
>  
>  static inline const char *skip_prefix(const char *str, const char
> *prefix)

The line above seems to have been broken by your email program. It is important for efficiency reasons that patches be readable directly out of emails (e.g., by using "git am"). Please practice by sending the patch to yourself different ways until "git am" works on it correctly.

Show 6 quoted lines
>  {
> -	size_t len = strlen(prefix);
> -	return strncmp(str, prefix, len) ? NULL : str + len;
> +	for (; ; str++, prefix++)
> +		if (!*prefix)
> +			return str;//code same as strbuf.c:starts_with()

We don't use "//" for comments, and please space things out the way other code does it. But actually, IMO this particular comment doesn't really belong permanently in the code. It rather belongs in the commit message, or in the discussion (under the "---"), or maybe it should be taken as an indication of a deeper problem (see below).

Show 6 quoted lines
> +		else if (*str != *prefix)
> +			return NULL;
>  }
>  
>  #if defined(NO_MMAP) || defined(USE_WIN32_MMAP)
> 
The code itself looks correct.

But, considering your comment, would it be appropriate for one of the functions to call the other?

Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: Faiz KothariNext: Faiz Kothari
Message 2 of 3 in “GSoC 2014 Microproject 1 rewrite skip_prefix() as loop”
  1. GSoC 2014 Microproject 1 rewrite skip_prefix() as loopFaiz Kothari, Feb 26, 2014
  2. Michael HaggertyFeb 27, 2014
  3. Faiz KothariFeb 27, 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.