Re: change symlink

2012-10-31 Thread Jeff King
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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-31 Thread Jeff King
On Wed, Oct 31, 2012 at 08:30:57AM -0400, Jeff King wrote:

 Something like this seems to fix it for me, but I am not sure if that
 would affect other callers.
 [...]
 + return !is_dir || !S_ISGITLINK(istate-cache[pos]-ce_mode);

That's completely wrong, of course. It should be:

  return is_dir  !S_ISGITLINK(...);

(we found an index entry, so if it isn't a directory, then we know that
it is not untracked, and should return 0).

With that, we at least pass the test suite.

-Peff
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread Andreas Schwab
shawn wilson ag4ve...@gmail.com writes:

 i'm curious why this is being reported as deleted in status and diff
 and not modified? this was tested on a build of the master branch of
 the current git repo (1.8.0).

 mkdir t cd t; git --init

 touch test
 git add test
 git commit test -m test

 ln -s test t2
 git add t2
 git commit t2 -m symlink

 rm t2
 mkdir -p t2/one
 ln -s test t2/one/test
  git add t2/one/test

 this then shows up as:

  % git status
 # On branch master
 # Changes not staged for commit:
 #   (use git add/rm file... to update what will be committed)
 #   (use git checkout -- file... to discard changes in working directory)
 #
 #   deleted:t2
 #
 no changes added to commit (use git add and/or git commit -a)

I'd expected t2/one/test be reported as untracked.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread shawn wilson
On Tue, Oct 30, 2012 at 9:19 PM, Andreas Schwab sch...@linux-m68k.org wrote:
 shawn wilson ag4ve...@gmail.com writes:

  % git status
 # On branch master
 # Changes not staged for commit:
 #   (use git add/rm file... to update what will be committed)
 #   (use git checkout -- file... to discard changes in working directory)
 #
 #   deleted:t2
 #
 no changes added to commit (use git add and/or git commit -a)

 I'd expected t2/one/test be reported as untracked.


that's fine - i can do 'git list-files --others' but should t2 be
reported as 'deleted'?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread Andreas Schwab
shawn wilson ag4ve...@gmail.com writes:

 but should t2 be reported as 'deleted'?

Sure, that's what you did.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread shawn wilson
On Tue, Oct 30, 2012 at 9:35 PM, Andreas Schwab sch...@linux-m68k.org wrote:
 shawn wilson ag4ve...@gmail.com writes:

 but should t2 be reported as 'deleted'?

 Sure, that's what you did.


if i do the same to a file (same repo):

touch test2
git add test2
git commit test2 -m test2

rm test
ln -s test2 test

git status

# On branch master
# Changes not staged for commit:
#   (use git add/rm file... to update what will be committed)
#   (use git checkout -- file... to discard changes in working directory)
#
#   deleted:t2
#   typechange: test
#
no changes added to commit (use git add and/or git commit -a)


why is this different?
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread Andreas Schwab
shawn wilson ag4ve...@gmail.com writes:

 why is this different?

You didn't tell git about t2/one/test.  You need to add it first to make
it known.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: change symlink

2012-10-30 Thread shawn wilson
On Tue, Oct 30, 2012 at 10:09 PM, Andreas Schwab sch...@linux-m68k.org wrote:
 shawn wilson ag4ve...@gmail.com writes:

 and once it's added, status says:
 #   renamed:t2 - t2/one/test

 that's not exactly true, but...

 What's wrong with it?  Both files have the same contents, which is the
 link target for symlinks.


ok, you're right about that (another test where i changed where the
symlink pointed):
#   deleted:test
#   new file:   test/one/t3


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