Re: change symlink

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 31, 2012 at 08:05:05AM -0400, Jeff King wrote:

> > 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];
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]