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

Re: git commit -a reports untracked files after a clone

From
Jeff King <peff@peff.net>
Date
May 27, 2011, 18:13 UTC
Message-ID
<20110527181321.GB29119@sigill.intra.peff.net>
In-Reply-To
<20110527180045.GA29119@sigill.intra.peff.net>
On Fri, May 27, 2011 at 02:00:45PM -0400, Jeff King wrote:
Show 11 quoted lines
>   1. We load the index, and for each entry, insert it into the index's
>      name_hash. In addition, if ignorecase is turned on, we make an
>      entry in the name_hash for the directory (e.g., "contrib/"), which
>      uses the following code from 5102c61's hash_index_entry_directories:
> 
>         hash = hash_name(ce->name, ptr - ce->name);
>         if (!lookup_hash(hash, &istate->name_hash)) {
>                 pos = insert_hash(hash, &istate->name_hash);
>                 ce->next = *pos;
>                 *pos = ce;
>         }

Urgh, sorry, I was looking at this on one of my topic branches which tweaked the calling convention of the hash code. All of my analysis is still valid, but the code in question actually looks like this:

          hash = hash_name(ce->name, ptr - ce->name);
          if (!lookup_hash(hash, &istate->name_hash)) {
                  pos = insert_hash(hash, ce, &istate->name_hash);
                  if (pos) {
                          ce->next = *pos;
                          *pos = ce;
                  }
          }
And therefore my patch needs tweaked slightly, too. Updated version is below.
diff --git a/cache.h b/cache.h
index 009b365..54f8c05 100644
--- a/cache.h
+++ b/cache.h
@@ -153,6 +153,7 @@ struct cache_entry {
 	unsigned int ce_flags;
 	unsigned char sha1[20];
 	struct cache_entry *next;
+	struct cache_entry *dir_next;
 	char name[FLEX_ARRAY]; /* more */
 };
 
diff --git a/name-hash.c b/name-hash.c
index c6b6a3f..225dd76 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -57,12 +57,10 @@ static void hash_index_entry_directories(struct index_state *istate, struct cach
 		if (*ptr == '/') {
 			++ptr;
 			hash = hash_name(ce->name, ptr - ce->name);
-			if (!lookup_hash(hash, &istate->name_hash)) {
-				pos = insert_hash(hash, ce, &istate->name_hash);
-				if (pos) {
-					ce->next = *pos;
-					*pos = ce;
-				}
+			pos = insert_hash(hash, ce, &istate->name_hash);
+			if (pos) {
+				ce->dir_next = *pos;
+				*pos = ce;
 			}
 		}
 	}
@@ -166,7 +164,10 @@ struct cache_entry *index_name_exists(struct index_state *istate, const char *na
 			if (same_name(ce, name, namelen, icase))
 				return ce;
 		}
-		ce = ce->next;
+		if (icase && name[namelen - 1] == '/')
+			ce = ce->dir_next;
+		else
+			ce = ce->next;
 	}
 
 	/*
-- 
1.7.5.3.12.g99e25.dirty
Previous: Jeff KingNext: Joerg Rosenkranz
Message 11 of 13 in “git commit -a reports untracked files after a clone”
  1. Philipp MetzlerMay 15, 2011
  2. Junio C HamanoMay 15, 2011
  3. Philipp MetzlerMay 15, 2011
  4. Jeff KingMay 16, 2011
  5. Philipp MetzlerMay 16, 2011
  6. Jeff KingMay 16, 2011
  7. Philipp MetzlerMay 16, 2011
  8. Philipp MetzlerMay 16, 2011
  9. Jeff KingMay 16, 2011
  10. Jeff KingMay 27, 2011
  11. Jeff KingMay 27, 2011
  12. Joerg RosenkranzOct 5, 2011
  13. Jeff KingOct 6, 2011

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.