{"thread":{"id":"31985","subject":"change symlink","startedAt":"2012-10-30T21:07:07Z","lastAt":"2012-10-31T13:44:32Z","messageCount":12,"participants":["shawn wilson","Andreas Schwab","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"202235","messageId":"CAH_OBie-irmpBrJG6KB3W8bgYjQdyVYiUR-SvJPnx1FXUya0uA@mail.gmail.com","threadId":"31985","inReplyTo":null,"subject":"change symlink","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2012-10-30T21:07:07Z","receivedAt":"2012-10-30T21:07:07Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"i'm curious why this is being reported as deleted in status and diff\nand not modified? this was tested on a build of the master branch of\nthe current git repo (1.8.0).\n\nmkdir t cd t; git --init\n\ntouch test\ngit add test\ngit commit test -m \"test\"\n\nln -s test t2\ngit add t2\ngit commit t2 -m \"symlink\"\n\nrm t2\nmkdir -p t2/one\nln -s test t2/one/test\n\nthis then shows up as:\n\n % git status\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#       deleted:    t2\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n % git --no-pager diff\ndiff --git a/t2 b/t2\ndeleted file mode 120000\nindex 30d74d2..0000000\n--- a/t2\n+++ /dev/null\n@@ -1 +0,0 @@\n-test\n\\\\ No newline at end of file\n"},{"id":"202238","messageId":"m2mwz3odys.fsf@igel.home","threadId":"31985","inReplyTo":"CAH_OBie-irmpBrJG6KB3W8bgYjQdyVYiUR-SvJPnx1FXUya0uA@mail.gmail.com","subject":"Re: change symlink","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-30T21:19:07Z","receivedAt":"2012-10-30T21:19:07Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"shawn wilson <ag4ve.us@gmail.com> writes:\n\n> i'm curious why this is being reported as deleted in status and diff\n> and not modified? this was tested on a build of the master branch of\n> the current git repo (1.8.0).\n>\n> mkdir t cd t; git --init\n>\n> touch test\n> git add test\n> git commit test -m \"test\"\n>\n> ln -s test t2\n> git add t2\n> git commit t2 -m \"symlink\"\n>\n> rm t2\n> mkdir -p t2/one\n> ln -s test t2/one/test\n  git add t2/one/test\n\n> this then shows up as:\n>\n>  % git status\n> # On branch master\n> # Changes not staged for commit:\n> #   (use \"git add/rm <file>...\" to update what will be committed)\n> #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n> #\n> #       deleted:    t2\n> #\n> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n\nI'd expected t2/one/test be reported as untracked.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202239","messageId":"CAH_OBidWxkhG3o4C4OPP4OxyQQfw_fF_h4C9KR9AnoOZ27=9TQ@mail.gmail.com","threadId":"31985","inReplyTo":"m2mwz3odys.fsf@igel.home","subject":"Re: change symlink","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2012-10-30T21:24:47Z","receivedAt":"2012-10-30T21:24:47Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Tue, Oct 30, 2012 at 9:19 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> shawn wilson <ag4ve.us@gmail.com> writes:\n\n>>  % git status\n>> # On branch master\n>> # Changes not staged for commit:\n>> #   (use \"git add/rm <file>...\" to update what will be committed)\n>> #   (use \"git checkout -- <file>...\" to discard changes in working directory)\n>> #\n>> #       deleted:    t2\n>> #\n>> no changes added to commit (use \"git add\" and/or \"git commit -a\")\n>\n> I'd expected t2/one/test be reported as untracked.\n>\n\nthat's fine - i can do 'git list-files --others' but should t2 be\nreported as 'deleted'?\n"},{"id":"202243","messageId":"m2fw4vod81.fsf@igel.home","threadId":"31985","inReplyTo":"CAH_OBidWxkhG3o4C4OPP4OxyQQfw_fF_h4C9KR9AnoOZ27=9TQ@mail.gmail.com","subject":"Re: change symlink","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-30T21:35:10Z","receivedAt":"2012-10-30T21:35:10Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"shawn wilson <ag4ve.us@gmail.com> writes:\n\n> but should t2 be reported as 'deleted'?\n\nSure, that's what you did.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202249","messageId":"CAH_OBifch3uuXYHQ1R9vS6xFu8LuY3mUfiPsHcs3F=HMvnBzyg@mail.gmail.com","threadId":"31985","inReplyTo":"m2fw4vod81.fsf@igel.home","subject":"Re: change symlink","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2012-10-30T21:42:44Z","receivedAt":"2012-10-30T21:42:44Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Tue, Oct 30, 2012 at 9:35 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> shawn wilson <ag4ve.us@gmail.com> writes:\n>\n>> but should t2 be reported as 'deleted'?\n>\n> Sure, that's what you did.\n>\n\nif i do the same to a file (same repo):\n\ntouch test2\ngit add test2\ngit commit test2 -m \"test2\"\n\nrm test\nln -s test2 test\n\ngit status\n\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working directory)\n#\n#       deleted:    t2\n#       typechange: test\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n\n\nwhy is this different?\n"},{"id":"202251","messageId":"m27gq7ochp.fsf@igel.home","threadId":"31985","inReplyTo":"CAH_OBifch3uuXYHQ1R9vS6xFu8LuY3mUfiPsHcs3F=HMvnBzyg@mail.gmail.com","subject":"Re: change symlink","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-30T21:50:58Z","receivedAt":"2012-10-30T21:50:58Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"shawn wilson <ag4ve.us@gmail.com> writes:\n\n> why is this different?\n\nYou didn't tell git about t2/one/test.  You need to add it first to make\nit known.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202254","messageId":"CAH_OBif=Zr-3GO3CE4D6O3wJJZysB6=vvmA37K6ujTHTr-un7w@mail.gmail.com","threadId":"31985","inReplyTo":"m27gq7ochp.fsf@igel.home","subject":"Re: change symlink","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2012-10-30T22:03:36Z","receivedAt":"2012-10-30T22:03:36Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Tue, Oct 30, 2012 at 9:50 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> shawn wilson <ag4ve.us@gmail.com> writes:\n>\n>> why is this different?\n>\n> You didn't tell git about t2/one/test.  You need to add it first to make\n> it known.\n>\n\nand once it's added, status says:\n#       renamed:    t2 -> t2/one/test\n\nthat's not exactly true, but...\n\ni guess the point is to only track files? if this is the case, i still\ndisagree with what status is reporting but i suppose it's fine (from a\nbug point of view).\n"},{"id":"202256","messageId":"m2390vobnh.fsf@igel.home","threadId":"31985","inReplyTo":"CAH_OBif=Zr-3GO3CE4D6O3wJJZysB6=vvmA37K6ujTHTr-un7w@mail.gmail.com","subject":"Re: change symlink","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2012-10-30T22:09:06Z","receivedAt":"2012-10-30T22:09:06Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"shawn wilson <ag4ve.us@gmail.com> writes:\n\n> and once it's added, status says:\n> #       renamed:    t2 -> t2/one/test\n>\n> that's not exactly true, but...\n\nWhat's wrong with it?  Both files have the same contents, which is the\nlink target for symlinks.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"202259","messageId":"CAH_OBidmrJsmw1QQ2WONieA1EQmS_Y4WJ8Mu2Mh90tEPU0uWgw@mail.gmail.com","threadId":"31985","inReplyTo":"m2390vobnh.fsf@igel.home","subject":"Re: change symlink","fromName":"shawn wilson","fromEmail":"ag4ve.us@gmail.com","sentAt":"2012-10-30T22:22:04Z","receivedAt":"2012-10-30T22:22:04Z","isPatch":false,"sender":{"key":"ag4ve.us@gmail.com","avatar":null},"body":"On Tue, Oct 30, 2012 at 10:09 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> shawn wilson <ag4ve.us@gmail.com> writes:\n>\n>> and once it's added, status says:\n>> #       renamed:    t2 -> t2/one/test\n>>\n>> that's not exactly true, but...\n>\n> What's wrong with it?  Both files have the same contents, which is the\n> link target for symlinks.\n>\n\nok, you're right about that (another test where i changed where the\nsymlink pointed):\n#       deleted:    test\n#       new file:   test/one/t3\n\n\nhowever (what got me started wondering about this and a point i forgot\nabout) - t2/one/test doesn't show up under 'untracked files' in in\nstatus that scenario. shouldn't it?\n"},{"id":"202303","messageId":"20121031120505.GD30879@sigill.intra.peff.net","threadId":"31985","inReplyTo":"CAH_OBidmrJsmw1QQ2WONieA1EQmS_Y4WJ8Mu2Mh90tEPU0uWgw@mail.gmail.com","subject":"Re: change symlink","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-31T12:05:05Z","receivedAt":"2012-10-31T12:05:05Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Oct 30, 2012 at 10:22:04PM +0000, shawn wilson wrote:\n\n> On Tue, Oct 30, 2012 at 10:09 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:\n> > shawn wilson <ag4ve.us@gmail.com> writes:\n> >\n> >> and once it's added, status says:\n> >> #       renamed:    t2 -> t2/one/test\n> >>\n> >> that's not exactly true, but...\n> >\n> > What's wrong with it?  Both files have the same contents, which is the\n> > link target for symlinks.\n> >\n> \n> ok, you're right about that (another test where i changed where the\n> symlink pointed):\n> #       deleted:    test\n> #       new file:   test/one/t3\n> \n> \n> however (what got me started wondering about this and a point i forgot\n> about) - t2/one/test doesn't show up under 'untracked files' in in\n> status that scenario. shouldn't it?\n\nYes, I think that is a bug.\n\nMy guess is that the presence of \"test\" in the index fools us from\ndescending into the directory. And indeed, if you try \"git status\n-uall\", you will see the untracked file. So it is something with the\ndirectory traversal cutoff in the regular \"-unormal\" mode.\n\n-Peff\n"},{"id":"202306","messageId":"20121031123057.GE30879@sigill.intra.peff.net","threadId":"31985","inReplyTo":"20121031120505.GD30879@sigill.intra.peff.net","subject":"Re: change symlink","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-31T12:30:57Z","receivedAt":"2012-10-31T12:30:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 31, 2012 at 08:05:05AM -0400, Jeff King wrote:\n\n> > however (what got me started wondering about this and a point i forgot\n> > about) - t2/one/test doesn't show up under 'untracked files' in in\n> > status that scenario. shouldn't it?\n> \n> Yes, I think that is a bug.\n> \n> My guess is that the presence of \"test\" in the index fools us from\n> descending into the directory. And indeed, if you try \"git status\n> -uall\", you will see the untracked file. So it is something with the\n> directory traversal cutoff in the regular \"-unormal\" mode.\n\nSomething like this seems to fix it for me, but I am not sure if that\nwould affect other callers.\n\ndiff --git a/read-cache.c b/read-cache.c\nindex fda78bc..ae04a61 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -1882,11 +1882,22 @@ int index_name_is_other(const struct index_state *istate, const char *name,\n \t\tint namelen)\n {\n \tint pos;\n-\tif (namelen && name[namelen - 1] == '/')\n+\tint is_dir = 0;\n+\n+\tif (namelen && name[namelen - 1] == '/') {\n \t\tnamelen--;\n+\t\tis_dir = 1;\n+\t}\n \tpos = index_name_pos(istate, name, namelen);\n-\tif (0 <= pos)\n-\t\treturn 0;\t/* exact match */\n+\tif (0 <= pos) {\n+\t\t/* We got an exact match. However, if it is a directory,\n+\t\t * we still have to check that the entry in the index\n+\t\t * is a directory, too. If it isn't, then the old file went\n+\t\t * away, and now we may have untracked files inside the newly\n+\t\t * created directory.\n+\t\t */\n+\t\treturn !is_dir || !S_ISGITLINK(istate->cache[pos]->ce_mode);\n+\t}\n \tpos = -pos - 1;\n \tif (pos < istate->cache_nr) {\n \t\tstruct cache_entry *ce = istate->cache[pos];\n"},{"id":"202310","messageId":"20121031134432.GA24518@sigill.intra.peff.net","threadId":"31985","inReplyTo":"20121031123057.GE30879@sigill.intra.peff.net","subject":"Re: change symlink","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-31T13:44:32Z","receivedAt":"2012-10-31T13:44:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Oct 31, 2012 at 08:30:57AM -0400, Jeff King wrote:\n\n> Something like this seems to fix it for me, but I am not sure if that\n> would affect other callers.\n> [...]\n> +\t\treturn !is_dir || !S_ISGITLINK(istate->cache[pos]->ce_mode);\n\nThat's completely wrong, of course. It should be:\n\n  return is_dir && !S_ISGITLINK(...);\n\n(we found an index entry, so if it isn't a directory, then we know that\nit is not untracked, and should return 0).\n\nWith that, we at least pass the test suite.\n\n-Peff\n"}]}