git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: shawn wilson <ag4ve.us@gmail.com>
Cc: Andreas Schwab <schwab@linux-m68k.org>, git@vger.kernel.org
Subject: Re: change symlink
Date: Wed, 31 Oct 2012 08:30:57 -0400	[thread overview]
Message-ID: <20121031123057.GE30879@sigill.intra.peff.net> (raw)
In-Reply-To: <20121031120505.GD30879@sigill.intra.peff.net>

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];

  reply	other threads:[~2012-10-31 12:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-30 21:07 change symlink shawn wilson
2012-10-30 21:19 ` Andreas Schwab
2012-10-30 21:24   ` shawn wilson
2012-10-30 21:35     ` Andreas Schwab
2012-10-30 21:42       ` shawn wilson
2012-10-30 21:50         ` Andreas Schwab
2012-10-30 22:03           ` shawn wilson
2012-10-30 22:09             ` Andreas Schwab
2012-10-30 22:22               ` shawn wilson
2012-10-31 12:05                 ` Jeff King
2012-10-31 12:30                   ` Jeff King [this message]
2012-10-31 13:44                     ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121031123057.GE30879@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=ag4ve.us@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).