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

Re: [RFH] index_name_exists() conversion

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 21, 2008, 16:15 UTC
Message-ID
<alpine.LFD.1.00.0802210806540.7833@woody.linux-foundation.org>
In-Reply-To
<7vy79evfsn.fsf@gitster.siamese.dyndns.org>
On Thu, 21 Feb 2008, Junio C Hamano wrote:
Show 12 quoted lines
>
>          struct dir_entry *dir_add_name(struct dir_struct *dir, const c...
>          {
>         -	if (cache_name_pos(pathname, len) >= 0)
>         +	if (cache_name_exists(pathname, len))
>                         return NULL;
> 
>                 ALLOC_GROW(dir->entries, dir->nr+1, dir->alloc);
> 
> This used to check if there is a stage#0 entry of that name in
> the index.  But the name-hash based index look-up does not care
> about the stage as far as I can tell.

I think the new code is much more correct, and we should always care about whether the name exists in the index, not whether it exists in stage#0.

IOW, if we ask for "show other files", we definitely want to ignore paths we already know about, and conversely, if we do an operation that is supposed to care about files in a directory we already know about, then an unmerged entry should count the same as a merged one.

> This could be related to the recent "status segfaults, bisected
> to cf558704" issue posted to the list.  I dunno.

Is there a backtrace for that? It's certainly possible that some strange path depended on only matching merged entries, but I would consider that unlikely and buggy.

The segfault is more likely related to something more subtle, like actually freeing a "cache_entry" after having removed it from the index (which we should never do - they were always supposed to stay around because they might not have been allocated with 'malloc()' in the first place, but with the name indexing thing it now is *always* a bug to do it, even if you _did_ allocate it with free()).

(Also, some code used to just reuse the same cache entry multiple times, and that got illegal for the same reason).

		Linus
Previous: Junio C HamanoNext: Johannes Schindelin
Message 3 of 10 in “[RFH] CE_REMOVE conversion”
  1. Junio C HamanoFeb 21, 2008
  2. [RFH] index_name_exists() conversionJunio C Hamano, Feb 21, 2008
  3. Linus TorvaldsFeb 21, 2008
  4. Johannes SchindelinFeb 21, 2008
  5. Linus TorvaldsFeb 21, 2008
  6. Linus TorvaldsFeb 21, 2008
  7. Junio C HamanoFeb 21, 2008
  8. Linus TorvaldsFeb 21, 2008
  9. Linus TorvaldsFeb 21, 2008
  10. Junio C HamanoFeb 21, 2008

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.