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

Re: change symlink

From
Jeff King <peff@peff.net>
Date
Oct 31, 2012, 12:30 UTC
Message-ID
<20121031123057.GE30879@sigill.intra.peff.net>
In-Reply-To
<20121031120505.GD30879@sigill.intra.peff.net>
On Wed, Oct 31, 2012 at 08:05:05AM -0400, Jeff King wrote:
Show 10 quoted lines
> > however (what got me started wondering about this and a point i forgot
> > about) - t2/one/test doesn't show up under 'untracked files' in in
> > status that scenario. shouldn't it?
> 
> Yes, I think that is a bug.
> 
> My guess is that the presence of "test" in the index fools us from
> descending into the directory. And indeed, if you try "git status
> -uall", you will see the untracked file. So it is something with the
> directory traversal cutoff in the regular "-unormal" mode.

Something like this seems to fix it for me, but I am not sure if that would affect other callers.

diff --git a/read-cache.c b/read-cache.c
index fda78bc..ae04a61 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -1882,11 +1882,22 @@ int index_name_is_other(const struct index_state *istate, const char *name,
 		int namelen)
 {
 	int pos;
-	if (namelen && name[namelen - 1] == '/')
+	int is_dir = 0;
+
+	if (namelen && name[namelen - 1] == '/') {
 		namelen--;
+		is_dir = 1;
+	}
 	pos = index_name_pos(istate, name, namelen);
-	if (0 <= pos)
-		return 0;	/* exact match */
+	if (0 <= pos) {
+		/* We got an exact match. However, if it is a directory,
+		 * we still have to check that the entry in the index
+		 * is a directory, too. If it isn't, then the old file went
+		 * away, and now we may have untracked files inside the newly
+		 * created directory.
+		 */
+		return !is_dir || !S_ISGITLINK(istate->cache[pos]->ce_mode);
+	}
 	pos = -pos - 1;
 	if (pos < istate->cache_nr) {
 		struct cache_entry *ce = istate->cache[pos];
Previous: Jeff KingNext: Jeff King
Message 11 of 12 in “change symlink”
  1. shawn wilsonOct 30, 2012
  2. Andreas SchwabOct 30, 2012
  3. shawn wilsonOct 30, 2012
  4. Andreas SchwabOct 30, 2012
  5. shawn wilsonOct 30, 2012
  6. Andreas SchwabOct 30, 2012
  7. shawn wilsonOct 30, 2012
  8. Andreas SchwabOct 30, 2012
  9. shawn wilsonOct 30, 2012
  10. Jeff KingOct 31, 2012
  11. Jeff KingOct 31, 2012
  12. Jeff KingOct 31, 2012

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.