All of lore.kernel.org
 help / color / mirror / Atom feed
* change symlink
@ 2012-10-30 21:07 shawn wilson
  2012-10-30 21:19 ` Andreas Schwab
  0 siblings, 1 reply; 12+ messages in thread
From: shawn wilson @ 2012-10-30 21:07 UTC (permalink / raw)
  To: git

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

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")
 % git --no-pager diff
diff --git a/t2 b/t2
deleted file mode 120000
index 30d74d2..0000000
--- a/t2
+++ /dev/null
@@ -1 +0,0 @@
-test
\\ No newline at end of file

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:07 change symlink shawn wilson
@ 2012-10-30 21:19 ` Andreas Schwab
  2012-10-30 21:24   ` shawn wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2012-10-30 21:19 UTC (permalink / raw)
  To: shawn wilson; +Cc: git

shawn wilson <ag4ve.us@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, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:19 ` Andreas Schwab
@ 2012-10-30 21:24   ` shawn wilson
  2012-10-30 21:35     ` Andreas Schwab
  0 siblings, 1 reply; 12+ messages in thread
From: shawn wilson @ 2012-10-30 21:24 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

On Tue, Oct 30, 2012 at 9:19 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> shawn wilson <ag4ve.us@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'?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:24   ` shawn wilson
@ 2012-10-30 21:35     ` Andreas Schwab
  2012-10-30 21:42       ` shawn wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2012-10-30 21:35 UTC (permalink / raw)
  To: shawn wilson; +Cc: git

shawn wilson <ag4ve.us@gmail.com> writes:

> but should t2 be reported as 'deleted'?

Sure, that's what you did.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:35     ` Andreas Schwab
@ 2012-10-30 21:42       ` shawn wilson
  2012-10-30 21:50         ` Andreas Schwab
  0 siblings, 1 reply; 12+ messages in thread
From: shawn wilson @ 2012-10-30 21:42 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

On Tue, Oct 30, 2012 at 9:35 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> shawn wilson <ag4ve.us@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?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:42       ` shawn wilson
@ 2012-10-30 21:50         ` Andreas Schwab
  2012-10-30 22:03           ` shawn wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2012-10-30 21:50 UTC (permalink / raw)
  To: shawn wilson; +Cc: git

shawn wilson <ag4ve.us@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, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 21:50         ` Andreas Schwab
@ 2012-10-30 22:03           ` shawn wilson
  2012-10-30 22:09             ` Andreas Schwab
  0 siblings, 1 reply; 12+ messages in thread
From: shawn wilson @ 2012-10-30 22:03 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

On Tue, Oct 30, 2012 at 9:50 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> shawn wilson <ag4ve.us@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.
>

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

that's not exactly true, but...

i guess the point is to only track files? if this is the case, i still
disagree with what status is reporting but i suppose it's fine (from a
bug point of view).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 22:03           ` shawn wilson
@ 2012-10-30 22:09             ` Andreas Schwab
  2012-10-30 22:22               ` shawn wilson
  0 siblings, 1 reply; 12+ messages in thread
From: Andreas Schwab @ 2012-10-30 22:09 UTC (permalink / raw)
  To: shawn wilson; +Cc: git

shawn wilson <ag4ve.us@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.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 22:09             ` Andreas Schwab
@ 2012-10-30 22:22               ` shawn wilson
  2012-10-31 12:05                 ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: shawn wilson @ 2012-10-30 22:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: git

On Tue, Oct 30, 2012 at 10:09 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> shawn wilson <ag4ve.us@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?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-30 22:22               ` shawn wilson
@ 2012-10-31 12:05                 ` Jeff King
  2012-10-31 12:30                   ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2012-10-31 12:05 UTC (permalink / raw)
  To: shawn wilson; +Cc: Andreas Schwab, git

On Tue, Oct 30, 2012 at 10:22:04PM +0000, shawn wilson wrote:

> On Tue, Oct 30, 2012 at 10:09 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> > shawn wilson <ag4ve.us@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?

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.

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-31 12:05                 ` Jeff King
@ 2012-10-31 12:30                   ` Jeff King
  2012-10-31 13:44                     ` Jeff King
  0 siblings, 1 reply; 12+ messages in thread
From: Jeff King @ 2012-10-31 12:30 UTC (permalink / raw)
  To: shawn wilson; +Cc: Andreas Schwab, git

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: change symlink
  2012-10-31 12:30                   ` Jeff King
@ 2012-10-31 13:44                     ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2012-10-31 13:44 UTC (permalink / raw)
  To: shawn wilson; +Cc: Andreas Schwab, git

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-31 13:44 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2012-10-31 13:44                     ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.