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

Broken adding of cache entries

From
Petr Baudis <pasky@ucw.cz>
Date
May 7, 2005, 15:28 UTC
Message-ID
<20050507152849.GD9495@pasky.ji.cz>
In-Reply-To
<1115431767.32065.182.camel@localhost.localdomain>

Dear diary, on Sat, May 07, 2005 at 04:09:27AM CEST, I got a letter where Kay Sievers <kay.sievers@vrfy.org> told me that... ..snip..

Show 8 quoted lines
> Look what funny thing you can do:
>   kay@mam:~/public_html/pub/scm/funny-tree$ git-ls-tree HEAD
>   100644  blob    b1a17ba136936531b72571844a773fe938b85ad4        entry
>   040000  tree    eba6ba02f18176500019755ad58c0bdfead16c47        entry
> 
> Add a file to the cache, replace it with a directory, add that to the
> cache and then write the tree and you have two entries with the same
> name. :)

Duh. Well, what could be the reasonwhy cache_name_compare() cares about flags at all? Can you _ever_ have two same-named entries? Junio, what do you think about something like this?

Index: read-cache.c
===================================================================
--- e47e2a558a85b33e0652233f78aa1ca8a959685b/read-cache.c  (mode:100644)
+++ uncommitted/read-cache.c  (mode:100644)
@@ -68,10 +68,6 @@
 		return -1;
 	if (len1 > len2)
 		return 1;
-	if (flags1 < flags2)
-		return -1;
-	if (flags1 > flags2)
-		return 1;
 	return 0;
 }
 
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
C++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor
Next: Junio C Hamano
Message 1 of 13 in “Broken adding of cache entries”
  1. Petr BaudisMay 7, 2005
  2. Junio C HamanoMay 7, 2005
  3. Junio C HamanoMay 7, 2005
  4. Petr BaudisMay 7, 2005
  5. Junio C HamanoMay 8, 2005
  6. Junio C HamanoMay 8, 2005
  7. Junio C HamanoMay 8, 2005
  8. Petr BaudisMay 8, 2005
  9. Junio C HamanoMay 8, 2005
  10. Petr BaudisMay 8, 2005
  11. Junio C HamanoMay 8, 2005
  12. Junio C HamanoMay 8, 2005
  13. Junio C HamanoMay 8, 2005

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.