{"thread":{"id":"27853","subject":"t5403.1 and adding a file that belongs to a submodule","startedAt":"2011-07-19T13:57:07Z","lastAt":"2011-07-20T17:50:34Z","messageCount":4,"participants":["Nguyen Thai Ngoc Duy","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171655","messageId":"CACsJy8AKMQa2u6Y5qQHGujbjqq0qnM5D1+aEvcfk7POxQBqsVg@mail.gmail.com","threadId":"27853","inReplyTo":null,"subject":"t5403.1 and adding a file that belongs to a submodule","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-07-19T13:57:07Z","receivedAt":"2011-07-19T13:57:07Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"A part of t5403.1 is like this\n\ntouch a b; git commit -am1\ngit clone ./. clone2\nGIT_DIR=clone2/.git git add clone2/b\n\nThe last command troubles me because clone2/.git is valid, I don't\nthink it should add \"clone2/b\" to clone2/.git/index. This is likely\ndue to common prefix optimization in read_directory, where it skips\nchecking .git at the first level (clone2). If we turn that command to\n\"git add a clone2/b\" (common prefix would be \"\"), the second argument\nis silently dropped (seems like a bug to me). Should t5403.1 be\nrewritten to avoid that construct?\n-- \nDuy\n"},{"id":"171660","messageId":"7vk4be9qqm.fsf@alter.siamese.dyndns.org","threadId":"27853","inReplyTo":"CACsJy8AKMQa2u6Y5qQHGujbjqq0qnM5D1+aEvcfk7POxQBqsVg@mail.gmail.com","subject":"Re: t5403.1 and adding a file that belongs to a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-07-19T16:31:29Z","receivedAt":"2011-07-19T16:31:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n\n> touch a b; git commit -am1\n> git clone ./. clone2\n> GIT_DIR=clone2/.git git add clone2/b\n\nThe last one has _always_ meant:\n\n    I am telling with GIT_DIR the directory that contains the repository\n    metadata, which is at clone2/.git directory.  I am not saying where\n    the working tree is (i.e. no GIT_WORK_TREE and no core.worktree in\n    clone2/.git/config) so take my $(pwd) as the root of the working tree,\n    and add the contents of clone2/b to the index at the same path,\n    i.e. \"clone2/b\".\n\nIt should not add contents of the said file at \"b\", as there is _nothing_\non the command line that tells us \"clone2\" is the root of the working\ntree.\n\nIf the test means to do that, it should be more explicit and do something\nlike:\n\n\t( cd clone2 && git add b )\n\ninstead.\n"},{"id":"171714","messageId":"CACsJy8AgboAj86PHi6jiSyRFsJJ7hn=mkbt+2UdBva6LmKk4ZQ@mail.gmail.com","threadId":"27853","inReplyTo":"7vk4be9qqm.fsf@alter.siamese.dyndns.org","subject":"Re: t5403.1 and adding a file that belongs to a submodule","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2011-07-20T00:17:09Z","receivedAt":"2011-07-20T00:17:09Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jul 19, 2011 at 11:31 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:\n>\n>> touch a b; git commit -am1\n>> git clone ./. clone2\n>> GIT_DIR=clone2/.git git add clone2/b\n>\n> The last one has _always_ meant:\n>\n>    I am telling with GIT_DIR the directory that contains the repository\n>    metadata, which is at clone2/.git directory.  I am not saying where\n>    the working tree is (i.e. no GIT_WORK_TREE and no core.worktree in\n>    clone2/.git/config) so take my $(pwd) as the root of the working tree,\n>    and add the contents of clone2/b to the index at the same path,\n>    i.e. \"clone2/b\".\n>\n> It should not add contents of the said file at \"b\", as there is _nothing_\n> on the command line that tells us \"clone2\" is the root of the working\n> tree.\n\nI see you're distracted by GIT_DIR. Let's take another example without GIT_DIR\n\ngit init\nmkdir foo\n(cd foo; git init; touch abc; git add abc; git ci -m1)\ngit add foo/abc\ngit ls-files --stage\n# 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0       foo/abc\n\nBecause foo is a repository, should we not allow \"git add foo/abc\"\n(\"git add foo\" is ok)? Otherwise \"abc\" may be managed in two\nrepositories.\n\nNote that doing \"touch abc; git add abc foo/abc\" instead will only add \"abc\".\n\n> If the test means to do that, it should be more explicit and do something\n> like:\n>\n>        ( cd clone2 && git add b )\n>\n> instead.\n\nI suspect that's what it wants. CC the author, hopefully he still remembers.\n-- \nDuy\n"},{"id":"171743","messageId":"7v1uxk96z9.fsf@alter.siamese.dyndns.org","threadId":"27853","inReplyTo":"CACsJy8AgboAj86PHi6jiSyRFsJJ7hn=mkbt+2UdBva6LmKk4ZQ@mail.gmail.com","subject":"Re: t5403.1 and adding a file that belongs to a submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-07-20T17:50:34Z","receivedAt":"2011-07-20T17:50:34Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> git init\n> mkdir foo\n> (cd foo; git init; touch abc; git add abc; git ci -m1)\n> git add foo/abc\n> Note that doing \"touch abc; git add abc foo/abc\" instead will only add \"abc\".\n\nI think you mean s/ci/commit/, but it is an (perhaps lower priority) bug\nin \"git add\". Good that you spotted it.\n"}]}