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

Re: Re: [PATCH] implement submodule config cache for lookup of submodule names

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 13, 2014, 00:46 UTC
Message-ID
<20140313004605.GC15625@google.com>
In-Reply-To
<20140312235833.GA5300@sandbox-ub>
Heiko Voigt wrote:
> On Tue, Mar 11, 2014 at 07:28:52PM -0700, Jonathan Nieder wrote:
>> Heiko Voigt wrote:
Show 10 quoted lines
>>> +static unsigned int hash_sha1_string(const unsigned char *sha1, const char *string)
>>> +{
>>> +	return memhash(sha1, 20) + strhash(string);
>>> +}
>>
>> Feels a bit unconventional.  I can't find a strong reason to mind.
>
> Well I did not think much about this. I simply thought: hash -> kind of
> random value. Adding the two together is as good as anything (even
> overflow does not matter).
[...]
> I am fine with a switch to something different. We could use classic XOR
> in case that feels better.

Either + or ^ is fine with me (yeah, '^' is what I expected so '+' forced me to think for a few seconds). I don't think we have to worry much about hostile people making repos that force git to spend a long time dealing with hash collisions, so anything more complicated is probably overkill. :)

[...]
Show 12 quoted lines
>> [...]
>>> +static void warn_multiple_config(struct submodule_config *config, const char *option)
>>> +{
>>> +	warning("%s:.gitmodules, multiple configurations found for submodule.%s.%s. "
>>> +			"Skipping second one!", sha1_to_hex(config->gitmodule_sha1),
>>> +			option, config->name.buf);
>>
>> Ah, so gitmodule_sha1 is a commit id?
>
> No, this output is a bug. gitmodule_sha1 is actually the sha1 of the
> .gitmodule blob we read. Thanks for noticing will fix. Should I also add
> a comment to the gitmodule_sha1 field to explain what it is?
[...]
>                                                                   with
> the clarification does the name make sense now?
Yep.  Suggested fixes:
 - call it gitmodules_sha1 instead of gitmodule_sha1 (it's the blob
   name for .gitmodules, not the name of a module)
 - add a comment where the field is declared (this would make it clear
   that it's a blob name instead of e.g. just the SHA-1 of the text)

Thanks for your thoughtfulness. Jonathan

Previous: Heiko Voigt
Message 6 of 6 in “implement submodule config cache for lookup of submodule names”
  1. implement submodule config cache for lookup of submodule namesHeiko Voigt, Mar 10, 2014
  2. Jeff KingMar 11, 2014
  3. Heiko VoigtMar 12, 2014
  4. Jonathan NiederMar 12, 2014
  5. Heiko VoigtMar 12, 2014
  6. Jonathan NiederMar 13, 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.