{"thread":{"id":"48728","subject":"Adding nested repository with slash adds files instead of gitlink","startedAt":"2018-06-18T11:19:46Z","lastAt":"2024-08-14T12:01:20Z","messageCount":22,"participants":["Heiko Voigt","Duy Nguyen","Kevin Daudt","Brandon Williams","Junio C Hamano","Rafael Ascensão","Phil Sainty","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"350376","messageId":"20180618111919.GA10085@book.hvoigt.net","threadId":"48728","inReplyTo":null,"subject":"Adding nested repository with slash adds files instead of gitlink","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2018-06-18T11:19:19Z","receivedAt":"2018-06-18T11:19:46Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nI just discovered that when you have a slash at the end of a nested\nrepository, the files contained in the repository get added instead of\nthe gitlink.\n\nI found this when I was adding a submodule and wanted to commit a small\nchange before that. You get the slash by using tab autocompletion.\n\nHere is a recipe to reproduce:\n\nmkdir test\ncd test; git init\ntouch a; git add a; git commit -m a\nmkdir ../test.git; (cd ../test.git; git init --bare)\ngit remote add origin ../test.git\ngit push origin master\ngit submodule add ../test.git submodule\ngit reset\ngit add submodule/\n\nNow instead of just submodule gitlink there is an entry for submodule/a\nin the index.\n\nI just thought I put this out there. Will have a look if I find the time\nto cook up a proper testcase and investigate.\n\nCheers Heiko\n"},{"id":"350386","messageId":"CACsJy8CJGditaq4CZfJctVAe9QCdapWQW=W--AumH-4RWWd=vA@mail.gmail.com","threadId":"48728","inReplyTo":"20180618111919.GA10085@book.hvoigt.net","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-18T15:06:07Z","receivedAt":"2018-06-18T15:14:32Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Jun 18, 2018 at 1:23 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n>\n> Hi,\n>\n> I just discovered that when you have a slash at the end of a nested\n> repository, the files contained in the repository get added instead of\n> the gitlink.\n>\n> I found this when I was adding a submodule and wanted to commit a small\n> change before that. You get the slash by using tab autocompletion.\n>\n> Here is a recipe to reproduce:\n>\n> mkdir test\n> cd test; git init\n> touch a; git add a; git commit -m a\n> mkdir ../test.git; (cd ../test.git; git init --bare)\n> git remote add origin ../test.git\n> git push origin master\n> git submodule add ../test.git submodule\n> git reset\n> git add submodule/\n>\n> Now instead of just submodule gitlink there is an entry for submodule/a\n> in the index.\n>\n> I just thought I put this out there. Will have a look if I find the time\n> to cook up a proper testcase and investigate.\n\nThis sounds like the submodule specific code in pathspec.c, which has\nbeen replaced with something else in bw/pathspec-sans-the-index. If\nyou have time, try a version without those changes (e.g. v2.13 or\nbefore) to see if it's a possible culprit.\n\n> Cheers Heiko\n\n\n\n-- \nDuy\n"},{"id":"350391","messageId":"20180618155544.GB6958@alpha","threadId":"48728","inReplyTo":"20180618111919.GA10085@book.hvoigt.net","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2018-06-18T15:55:44Z","receivedAt":"2018-06-18T15:55:48Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Mon, Jun 18, 2018 at 01:19:19PM +0200, Heiko Voigt wrote:\n\nNow with cc to the mailing list.\n\n> Hi,\n> \n> I just discovered that when you have a slash at the end of a nested\n> repository, the files contained in the repository get added instead of\n> the gitlink.\n> \n> I found this when I was adding a submodule and wanted to commit a small\n> change before that. You get the slash by using tab autocompletion.\n> \n> Here is a recipe to reproduce:\n> \n> mkdir test\n> cd test; git init\n> touch a; git add a; git commit -m a\n> mkdir ../test.git; (cd ../test.git; git init --bare)\n> git remote add origin ../test.git\n> git push origin master\n> git submodule add ../test.git submodule\n> git reset\n> git add submodule/\n> \n> Now instead of just submodule gitlink there is an entry for submodule/a\n> in the index.\n> \n> I just thought I put this out there. Will have a look if I find the time\n> to cook up a proper testcase and investigate.\n> \n> Cheers Heiko\n\nThis has been the case as far as I can remember, and is basically lore\nin the #git irc channel).\n\nThis can also be reproduced by just cloning a repo inside another repo\nand running `git add path/`.\n"},{"id":"350406","messageId":"20180618181215.GB73085@google.com","threadId":"48728","inReplyTo":"CACsJy8CJGditaq4CZfJctVAe9QCdapWQW=W--AumH-4RWWd=vA@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Brandon Williams","fromEmail":"bmwill@google.com","sentAt":"2018-06-18T18:12:15Z","receivedAt":"2018-06-18T18:12:21Z","isPatch":false,"sender":{"key":"bwilliams.eng@gmail.com","avatar":null},"body":"On 06/18, Duy Nguyen wrote:\n> On Mon, Jun 18, 2018 at 1:23 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> >\n> > Hi,\n> >\n> > I just discovered that when you have a slash at the end of a nested\n> > repository, the files contained in the repository get added instead of\n> > the gitlink.\n> >\n> > I found this when I was adding a submodule and wanted to commit a small\n> > change before that. You get the slash by using tab autocompletion.\n> >\n> > Here is a recipe to reproduce:\n> >\n> > mkdir test\n> > cd test; git init\n> > touch a; git add a; git commit -m a\n> > mkdir ../test.git; (cd ../test.git; git init --bare)\n> > git remote add origin ../test.git\n> > git push origin master\n> > git submodule add ../test.git submodule\n> > git reset\n> > git add submodule/\n> >\n> > Now instead of just submodule gitlink there is an entry for submodule/a\n> > in the index.\n> >\n> > I just thought I put this out there. Will have a look if I find the time\n> > to cook up a proper testcase and investigate.\n> \n> This sounds like the submodule specific code in pathspec.c, which has\n> been replaced with something else in bw/pathspec-sans-the-index. If\n> you have time, try a version without those changes (e.g. v2.13 or\n> before) to see if it's a possible culprit.\n\nI just tested this with v2.13 and saw the same issue.  I don't actually\nthink this ever worked in the way you want it to Heiko.  Maybe git add\nneeds to be taught to be more intelligent when trying to add a submodule\nwhich doesn't exist in the index.\n\n-- \nBrandon Williams\n"},{"id":"350463","messageId":"20180619102717.GB10085@book.hvoigt.net","threadId":"48728","inReplyTo":"20180618155544.GB6958@alpha","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2018-06-19T10:27:17Z","receivedAt":"2018-06-19T10:26:57Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"Hi,\n\nOn Mon, Jun 18, 2018 at 05:55:44PM +0200, Kevin Daudt wrote:\n> On Mon, Jun 18, 2018 at 01:19:19PM +0200, Heiko Voigt wrote:\n> > I just discovered that when you have a slash at the end of a nested\n> > repository, the files contained in the repository get added instead of\n> > the gitlink.\n[...]\n> > \n> > I just thought I put this out there. Will have a look if I find the time\n> > to cook up a proper testcase and investigate.\n> > \n> > Cheers Heiko\n> \n> This has been the case as far as I can remember, and is basically lore\n> in the #git irc channel).\n> \n> This can also be reproduced by just cloning a repo inside another repo\n> and running `git add path/`.\n\nInteresting and nobody complained to the mailinglist? IMO, there is no\nreason 'git add path' and 'git add path/' should behave differently or\nis there?\n\nSo it seems it is a very seldom operation (in my daily work it is at\nleast) and people just accepted it as a quirk of git.\n\nIf someone wants to look into changing this feel free, otherwise I will\nhave a look, but I am not sure when yet.\n\nCheers Heiko\n"},{"id":"350464","messageId":"20180619103632.GC10085@book.hvoigt.net","threadId":"48728","inReplyTo":"20180618181215.GB73085@google.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Heiko Voigt","fromEmail":"hvoigt@hvoigt.net","sentAt":"2018-06-19T10:36:32Z","receivedAt":"2018-06-19T10:36:10Z","isPatch":false,"sender":{"key":"hvoigt@hvoigt.net","avatar":"https://avatars.githubusercontent.com/u/184958?v=4"},"body":"On Mon, Jun 18, 2018 at 11:12:15AM -0700, Brandon Williams wrote:\n> On 06/18, Duy Nguyen wrote:\n> > This sounds like the submodule specific code in pathspec.c, which has\n> > been replaced with something else in bw/pathspec-sans-the-index. If\n> > you have time, try a version without those changes (e.g. v2.13 or\n> > before) to see if it's a possible culprit.\n> \n> I just tested this with v2.13 and saw the same issue.  I don't actually\n> think this ever worked in the way you want it to Heiko.  Maybe git add\n> needs to be taught to be more intelligent when trying to add a submodule\n> which doesn't exist in the index.\n\nThat was also my guess, since my feeling is that this is a quite rare\nuse case. Adding submodules alone is not a daily thing, let alone\nselecting different changes after 'git submodule add'.\n\nI also think git could be more intelligent here.\n\nCheers Heiko\n"},{"id":"350477","messageId":"CACsJy8DQ-GGEDiV0iA2kTgNgHcT1sSX2Oqb7VZcjyK1nBOFv+A@mail.gmail.com","threadId":"48728","inReplyTo":"20180619103632.GC10085@book.hvoigt.net","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-19T15:16:17Z","receivedAt":"2018-06-19T15:16:47Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jun 19, 2018 at 12:36 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n>\n> On Mon, Jun 18, 2018 at 11:12:15AM -0700, Brandon Williams wrote:\n> > On 06/18, Duy Nguyen wrote:\n> > > This sounds like the submodule specific code in pathspec.c, which has\n> > > been replaced with something else in bw/pathspec-sans-the-index. If\n> > > you have time, try a version without those changes (e.g. v2.13 or\n> > > before) to see if it's a possible culprit.\n> >\n> > I just tested this with v2.13 and saw the same issue.  I don't actually\n> > think this ever worked in the way you want it to Heiko.  Maybe git add\n> > needs to be taught to be more intelligent when trying to add a submodule\n> > which doesn't exist in the index.\n>\n> That was also my guess, since my feeling is that this is a quite rare\n> use case. Adding submodules alone is not a daily thing, let alone\n> selecting different changes after 'git submodule add'.\n>\n> I also think git could be more intelligent here.\n\nAh.. the \"submodule not registered in index\" case. I think I remember\nthis (because I remember complaining about it once or two times).\nDefinitely agreed that git-add should do the right thing here.\n\nBrandon already moved the submodule check outside pathspec code\n(wonderful!) so adding more checks based on worktree state should not\nbe a big work. I think the only concern here is catching submodule\nlocations so we don't check submodule at the same location multiple\ntimes.\n\nNo actually, we could do better. Let me see if I can come up with a\npatch or something...\n-- \nDuy\n"},{"id":"350484","messageId":"xmqqmuvqwz07.fsf@gitster-ct.c.googlers.com","threadId":"48728","inReplyTo":"CACsJy8DQ-GGEDiV0iA2kTgNgHcT1sSX2Oqb7VZcjyK1nBOFv+A@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-06-19T15:56:56Z","receivedAt":"2018-06-19T15:57:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Duy Nguyen <pclouds@gmail.com> writes:\n\n> On Tue, Jun 19, 2018 at 12:36 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n>>\n>> On Mon, Jun 18, 2018 at 11:12:15AM -0700, Brandon Williams wrote:\n>> > On 06/18, Duy Nguyen wrote:\n>> > > This sounds like the submodule specific code in pathspec.c, which has\n>> > > been replaced with something else in bw/pathspec-sans-the-index. If\n>> > > you have time, try a version without those changes (e.g. v2.13 or\n>> > > before) to see if it's a possible culprit.\n>> >\n>> > I just tested this with v2.13 and saw the same issue.  I don't actually\n>> > think this ever worked in the way you want it to Heiko.  Maybe git add\n>> > needs to be taught to be more intelligent when trying to add a submodule\n>> > which doesn't exist in the index.\n>>\n>> That was also my guess, since my feeling is that this is a quite rare\n>> use case. Adding submodules alone is not a daily thing, let alone\n>> selecting different changes after 'git submodule add'.\n>>\n>> I also think git could be more intelligent here.\n>\n> Ah.. the \"submodule not registered in index\" case. I think I remember\n> this (because I remember complaining about it once or two times).\n> Definitely agreed that git-add should do the right thing here.\n\nI am not sure if this even needs to be implemented as \"look for the\nsubmodule in the index\".  Even before submodule was added, we knew\nthat \"git add foo/bar\" should reject the request if we find foo is a\nsymbolic link, and we should do the same when foo/ is a directory\nthat is the top of a working tree under control of another\nrepository, no?\n\nHmm, what happens when we do this?\n\n\tgit init\n\tln -s /tmp foo\n\t>foo/bar\n\tgit add foo/\n\nI think we should say either \"let's add foo symlink\" or\n\"foo/. (directory) is beyond symlink\" (the latter is preferrable,\nbut the former is acceptable as long as foo is pointing at a\ndirectory; but foo could be a dangling symlink whose pointee's type\nmay not be discernable by \"git add\").\n\nShouldn't we be reacting pretty much the same when we see this?\n\n\tgit init\n\tgit init foo\n\t>foo/bar\n\tgit add foo/\n\nThat is, either drop '/' and add 'foo' as a submodule, or say\n\"foo/. (directory) belongs to another repository, cannot add here\"\n(again, the latter is preferrable for consistency with the symlink\nbehaviour above).\n\n"},{"id":"350488","messageId":"CACsJy8CVUzFDU+4xf+bZW63F=hX5EmAbW+LvqW737AGTLbUj7g@mail.gmail.com","threadId":"48728","inReplyTo":"xmqqmuvqwz07.fsf@gitster-ct.c.googlers.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-19T16:11:53Z","receivedAt":"2018-06-19T16:12:32Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jun 19, 2018 at 5:56 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Duy Nguyen <pclouds@gmail.com> writes:\n>\n> > On Tue, Jun 19, 2018 at 12:36 PM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> >>\n> >> On Mon, Jun 18, 2018 at 11:12:15AM -0700, Brandon Williams wrote:\n> >> > On 06/18, Duy Nguyen wrote:\n> >> > > This sounds like the submodule specific code in pathspec.c, which has\n> >> > > been replaced with something else in bw/pathspec-sans-the-index. If\n> >> > > you have time, try a version without those changes (e.g. v2.13 or\n> >> > > before) to see if it's a possible culprit.\n> >> >\n> >> > I just tested this with v2.13 and saw the same issue.  I don't actually\n> >> > think this ever worked in the way you want it to Heiko.  Maybe git add\n> >> > needs to be taught to be more intelligent when trying to add a submodule\n> >> > which doesn't exist in the index.\n> >>\n> >> That was also my guess, since my feeling is that this is a quite rare\n> >> use case. Adding submodules alone is not a daily thing, let alone\n> >> selecting different changes after 'git submodule add'.\n> >>\n> >> I also think git could be more intelligent here.\n> >\n> > Ah.. the \"submodule not registered in index\" case. I think I remember\n> > this (because I remember complaining about it once or two times).\n> > Definitely agreed that git-add should do the right thing here.\n>\n> I am not sure if this even needs to be implemented as \"look for the\n> submodule in the index\".  Even before submodule was added, we knew\n> that \"git add foo/bar\" should reject the request if we find foo is a\n> symbolic link, and we should do the same when foo/ is a directory\n> that is the top of a working tree under control of another\n> repository, no?\n\nExactly. I started with the intention to do something related to the\nindex only to slowly realize that it was not the right place. We\ntraverse directories and stop looking inside a symlink, we can do the\nsame if we realize it's a submodule.\n-- \nDuy\n"},{"id":"350489","messageId":"20180619160956.GA21384@duynguyen.home","threadId":"48728","inReplyTo":"CACsJy8DQ-GGEDiV0iA2kTgNgHcT1sSX2Oqb7VZcjyK1nBOFv+A@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-19T16:09:57Z","receivedAt":"2018-06-19T16:13:06Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jun 19, 2018 at 05:16:17PM +0200, Duy Nguyen wrote:\n> No actually, we could do better. Let me see if I can come up with a\n> patch or something...\n\nOK. What we currently do is, when we search for potential untracked\npaths for adding to the index, we unconditionally ignore anything\ninside \".git\". For example, if \"foo\" is a submodule, \"git add .\" will\nvisit \"foo/.git\" then ignore its content completely.\n\nWe could do something very similar: when we visit \"foo\", if \"foo/.git\"\nexists, we ignore it as well. In other words, we extend from \"ignore\nanything inside a git repository\" to \"ignore anything inside any other\ngit worktree\".\n\nThe following patch basically does that. If you specify \"git add\nfoo/bar\". It will still visit \"foo\" first, realize that it's a\nsubmodule and drop it. At the end, it will not report foo/bar as an\nuntracked (i.e. add-able) entry, so you can't add it.\n\nI didn't test it extensively to see if it breaks anything though. And\nI might need to check how it affects untracked cache...\n\n-- 8< --\ndiff --git a/dir.c b/dir.c\nindex fe9bf58e4c..8a1a5d8dd5 100644\n--- a/dir.c\n+++ b/dir.c\n@@ -1672,6 +1672,17 @@ static enum path_treatment treat_one_path(struct dir_struct *dir,\n \tif (dtype != DT_DIR && has_path_in_index)\n \t\treturn path_none;\n \n+\tif (dtype == DT_DIR) {\n+\t\tint path_len = path->len;\n+\t\tint is_submodule;\n+\n+\t\tstrbuf_addstr(path, \"/.git\");\n+\t\tis_submodule = is_directory(path->buf);\n+\t\tstrbuf_setlen(path, path_len);\n+\t\tif (is_submodule)\n+\t\t\treturn path_none;\n+\t}\n+\n \t/*\n \t * When we are looking at a directory P in the working tree,\n \t * there are three cases:\n-- 8< --\n"},{"id":"350490","messageId":"CACsJy8CR=Oo8pEGK=5uSizQKi1Fg8eitbLO19LjqiR53uDC0hA@mail.gmail.com","threadId":"48728","inReplyTo":"20180619160956.GA21384@duynguyen.home","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-19T16:20:27Z","receivedAt":"2018-06-19T16:20:57Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Jun 19, 2018 at 6:09 PM Duy Nguyen <pclouds@gmail.com> wrote:\n> On Tue, Jun 19, 2018 at 05:16:17PM +0200, Duy Nguyen wrote:\n> > No actually, we could do better. Let me see if I can come up with a\n> > patch or something...\n>\n> OK. What we currently do is, when we search for potential untracked\n> paths for adding to the index, we unconditionally ignore anything\n> inside \".git\". For example, if \"foo\" is a submodule, \"git add .\" will\n> visit \"foo/.git\" then ignore its content completely.\n>\n> We could do something very similar: when we visit \"foo\", if \"foo/.git\"\n> exists, we ignore it as well. In other words, we extend from \"ignore\n> anything inside a git repository\" to \"ignore anything inside any other\n> git worktree\".\n>\n> The following patch basically does that. If you specify \"git add\n> foo/bar\". It will still visit \"foo\" first, realize that it's a\n> submodule and drop it. At the end, it will not report foo/bar as an\n> untracked (i.e. add-able) entry, so you can't add it.\n\nAnother note (which I added, then thought otherwise and dropped). I\nbelieve this approach also solves the problem that\ndie_path_inside_submodule() tries to work around.\n\nWhen you feed a path inside a submodule, read_directory() code does\nnot realize it and walk through like it's part of the current worktree\n(wrong!). But if read_directory() does the right thing from the\nbeginning, you don't need this trick. We don't even need this trick if\na submodule is not real on worktree (no \".git\" directory there) but\nregistered in the index as a git link because the d/f check should\ncatch that and complain loudly anyway when you add a new entry.\n-- \nDuy\n"},{"id":"350541","messageId":"CACUQV5884fs2wp+R5a-99BbJGdEbujzu2iBny+PjPeL9JeOm8Q@mail.gmail.com","threadId":"48728","inReplyTo":"20180619102717.GB10085@book.hvoigt.net","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Rafael Ascensão","fromEmail":"rafa.almas@gmail.com","sentAt":"2018-06-19T22:29:02Z","receivedAt":"2018-06-19T22:29:45Z","isPatch":false,"sender":{"key":"rafa.almas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1923789?v=4"},"body":"On Tue, Jun 19, 2018 at 11:28 AM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n>\n> Interesting and nobody complained to the mailinglist?\n>\n\nFor reference this was sometimes called \"Fake Submodules\" online.\n"},{"id":"350550","messageId":"20180620043956.GC6958@alpha","threadId":"48728","inReplyTo":"CACUQV5884fs2wp+R5a-99BbJGdEbujzu2iBny+PjPeL9JeOm8Q@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2018-06-20T04:39:56Z","receivedAt":"2018-06-20T04:40:01Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Tue, Jun 19, 2018 at 11:29:02PM +0100, Rafael Ascensão wrote:\n> On Tue, Jun 19, 2018 at 11:28 AM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n> >\n> > Interesting and nobody complained to the mailinglist?\n> >\n> \n> For reference this was sometimes called \"Fake Submodules\" online.\n\nDo you refer to cloning a repository in another repository, and running\n`git add path` (no trailing /) so that a gitlink is created without a\n.gitmodules file? Because that's not what Heiko is referring to.\n\nWhat this is about that when doing `git add path/` (with trailing /),\ngit will add the files of the cloned repository to the parent repo, and\nbasically ignore that it's another repository.\n\nAnd I guess no one complained because it looked like a feature rather\nthan a bug.\n\nKevin\n"},{"id":"350559","messageId":"CACUQV5-ynAv0p9MCRt0Yv9E6x+UN5z4uuaPOt1GpsK6A6MF2wQ@mail.gmail.com","threadId":"48728","inReplyTo":"20180620043956.GC6958@alpha","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Rafael Ascensão","fromEmail":"rafa.almas@gmail.com","sentAt":"2018-06-20T11:52:49Z","receivedAt":"2018-06-20T11:53:31Z","isPatch":false,"sender":{"key":"rafa.almas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1923789?v=4"},"body":"On Wed, Jun 20, 2018 at 5:39 AM Kevin Daudt <me@ikke.info> wrote:\n>\n> What this is about that when doing `git add path/` (with trailing /),\n>\n\nThis is what I was referring to. If you search for 'Fake Submodules',\nyou'll see that some people were/are intentionally using this instead of\nsubtrees or submodules. Unfortunately the original article [1] seems to\nbe dead, but searching url in the mailing list archives leads to some\nadditional discussion on the subject [2,3].\n\n\n[1]:http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb\n[2]:https://public-inbox.org/git/xmqqy47o6q71.fsf@gitster.mtv.corp.google.com/\n[3]:https://public-inbox.org/git/CAGZ79kZofg3jS+g0weTdco+PGo_p-_Hd-NScZ=q2UfB7tF2GPA@mail.gmail.com/\n"},{"id":"350564","messageId":"CACsJy8CW1=Ea984s8J0Y6y4B6qJKZMdsXVFRQc8YcuoQNfXEqw@mail.gmail.com","threadId":"48728","inReplyTo":"CACUQV5-ynAv0p9MCRt0Yv9E6x+UN5z4uuaPOt1GpsK6A6MF2wQ@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-20T14:57:25Z","receivedAt":"2018-06-20T14:57:55Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Jun 20, 2018 at 1:55 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:\n>\n> On Wed, Jun 20, 2018 at 5:39 AM Kevin Daudt <me@ikke.info> wrote:\n> >\n> > What this is about that when doing `git add path/` (with trailing /),\n> >\n>\n> This is what I was referring to. If you search for 'Fake Submodules',\n> you'll see that some people were/are intentionally using this instead of\n> subtrees or submodules. Unfortunately the original article [1] seems to\n> be dead, but searching url in the mailing list archives leads to some\n> additional discussion on the subject [2,3].\n\nAbusing a long standing bug does not make it a feature. I'm not\nopposed to having a new option to keep that behavior, but it should\nnot be the default. If you use it that way, you're on your own.\n\n> [1]:http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb\n> [2]:https://public-inbox.org/git/xmqqy47o6q71.fsf@gitster.mtv.corp.google.com/\n> [3]:https://public-inbox.org/git/CAGZ79kZofg3jS+g0weTdco+PGo_p-_Hd-NScZ=q2UfB7tF2GPA@mail.gmail.com/\n-- \nDuy\n"},{"id":"350569","messageId":"CACUQV5-BXQ3PLZ6aiZEqHS39yv4ZJbg_cKwMDCZvHBD6Op_g2A@mail.gmail.com","threadId":"48728","inReplyTo":"CACsJy8CW1=Ea984s8J0Y6y4B6qJKZMdsXVFRQc8YcuoQNfXEqw@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Rafael Ascensão","fromEmail":"rafa.almas@gmail.com","sentAt":"2018-06-20T16:21:38Z","receivedAt":"2018-06-20T16:22:19Z","isPatch":false,"sender":{"key":"rafa.almas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1923789?v=4"},"body":"On Tue, Jun 19, 2018 at 11:28 AM Heiko Voigt <hvoigt@hvoigt.net> wrote:\n>\n> Interesting and nobody complained to the mailinglist?\n>\n\nOn Wed, Jun 20, 2018 at 3:57 PM Duy Nguyen <pclouds@gmail.com> wrote:\n>\n> Abusing a long standing bug does not make it a feature.\n>\n\nTo make things clear, I wasn't defending if this should be considered a\nbug or a feature. Was just clarifying that this isn't a newly discovered\nthing and was reported/discussed in the past.\n\n--\nCheers,\nRafael\n"},{"id":"500430","messageId":"s5wr0azfeh9.fsf@catalyst.net.nz","threadId":"48728","inReplyTo":"CACsJy8CW1=Ea984s8J0Y6y4B6qJKZMdsXVFRQc8YcuoQNfXEqw@mail.gmail.com","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Phil Sainty","fromEmail":"phil@catalyst.net.nz","sentAt":"2024-08-08T11:20:18Z","receivedAt":"2024-08-08T11:29:29Z","isPatch":false,"sender":{"key":"phil@catalyst.net.nz","avatar":null},"body":"> On Wed, Jun 20, 2018 at 1:55 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:\n> > On Wed, Jun 20, 2018 at 5:39 AM Kevin Daudt <me@ikke.info> wrote:\n> > > What this is about that when doing `git add path/` (with trailing /),\n> >\n> > This is what I was referring to. If you search for 'Fake Submodules',\n> > you'll see that some people were/are intentionally using this instead of\n> > subtrees or submodules. Unfortunately the original article [1] seems to\n> > be dead, but searching url in the mailing list archives leads to some\n> > additional discussion on the subject [2,3].\n>\n> Abusing a long standing bug does not make it a feature. I'm not\n> opposed to having a new option to keep that behavior, but it should\n> not be the default. If you use it that way, you're on your own.\n\nWas such an option ever worked on?\n\n(I.e. a way to git-add some sub-directory 'foo' which contains another\nrepository, and have git-add act as if foo/.git didn't exist -- simply\nadding the (other) contents of foo to the containing repo's index.)\n\nI haven't spotted anything in the git-add man page for v2.34, nor in the\nrelease notes for subsequent git versions.\n\nThe old behaviour was a genuinely useful ability which I've used a great\nin the past, and if there's any convenient way to achieve the same thing\nnowadays, I've failed to find it.  (One can temporarily move the nested\n.git directory elsewhere, run git-add, and then move the .git directory\nback again; but that's frustratingly cumbersome by comparison).\n\nIf I haven't missed some existing solution, could a new git-add option\nfor restoring this ability be implemented?\n\n\n-Phil\n\n\n> > [1]:http://debuggable.com/posts/git-fake-submodules:4b563ee4-f3cc-4061-967e-0e48cbdd56cb\n> > [2]:https://public-inbox.org/git/xmqqy47o6q71.fsf@gitster.mtv.corp.google.com/\n> > [3]:https://public-inbox.org/git/CAGZ79kZofg3jS+g0weTdco+PGo_p-_Hd-NScZ=q2UfB7tF2GPA@mail.gmail.com/\n"},{"id":"500501","messageId":"xmqqed6zht04.fsf@gitster.g","threadId":"48728","inReplyTo":"s5wr0azfeh9.fsf@catalyst.net.nz","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-08T16:35:55Z","receivedAt":"2024-08-08T16:35:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Sainty <phil@catalyst.net.nz> writes:\n\n>> On Wed, Jun 20, 2018 at 1:55 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:\n>> > On Wed, Jun 20, 2018 at 5:39 AM Kevin Daudt <me@ikke.info> wrote:\n>> > > What this is about that when doing `git add path/` (with trailing /),\n>> >\n>> > This is what I was referring to. If you search for 'Fake Submodules',\n>> > you'll see that some people were/are intentionally using this instead of\n>> > subtrees or submodules. Unfortunately the original article [1] seems to\n>> > be dead, but searching url in the mailing list archives leads to some\n>> > additional discussion on the subject [2,3].\n>>\n>> Abusing a long standing bug does not make it a feature. I'm not\n>> opposed to having a new option to keep that behavior, but it should\n>> not be the default. If you use it that way, you're on your own.\n>\n> Was such an option ever worked on?\n\nNo.  \n\nI do not recall hearing anybody who have been active in the\ndevelopment community saying anything good about such an option.\nFor the past 6 or so years, nobody who actively works on git thought\nit was an interesting and/or useful thing to work on.\n\nI cannot quite say that they thought that it is actively a bad idea\nto offer such an option, though.\n"},{"id":"500773","messageId":"8436c2bf-45cf-8009-14cd-c5ca708ece08@gmx.de","threadId":"48728","inReplyTo":"xmqqed6zht04.fsf@gitster.g","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2024-08-13T12:48:47Z","receivedAt":"2024-08-13T12:49:10Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 8 Aug 2024, Junio C Hamano wrote:\n\n> Phil Sainty <phil@catalyst.net.nz> writes:\n>\n> >> On Wed, Jun 20, 2018 at 1:55 PM Rafael Ascensão <rafa.almas@gmail.com> wrote:\n> >> > On Wed, Jun 20, 2018 at 5:39 AM Kevin Daudt <me@ikke.info> wrote:\n> >> > > What this is about that when doing `git add path/` (with trailing /),\n> >> >\n> >> > This is what I was referring to. If you search for 'Fake Submodules',\n> >> > you'll see that some people were/are intentionally using this instead of\n> >> > subtrees or submodules. Unfortunately the original article [1] seems to\n> >> > be dead, but searching url in the mailing list archives leads to some\n> >> > additional discussion on the subject [2,3].\n> >>\n> >> Abusing a long standing bug does not make it a feature. I'm not\n> >> opposed to having a new option to keep that behavior, but it should\n> >> not be the default. If you use it that way, you're on your own.\n> >\n> > Was such an option ever worked on?\n>\n> No.\n>\n> I do not recall hearing anybody who have been active in the\n> development community saying anything good about such an option.\n> For the past 6 or so years, nobody who actively works on git thought\n> it was an interesting and/or useful thing to work on.\n>\n> I cannot quite say that they thought that it is actively a bad idea\n> to offer such an option, though.\n\nI have encountered the wish quite frequently to be able to make changes in\na subdirectory and have them reflected as a commit that is both part of\nthat subdirectory's revision history as well as part of the containing\nproject's.\n\nThe benefits for monorepos, and for reproducible builds, are probably\nobvious.\n\nSadly, I cannot think of an elegant technical design, and this is not for\nlack of trying.\n\nThere are lots of projects I worked on that would have benefitted from\nbeing able to track a subdirectory both independently as well as within\nthe context of a containing project, i.e. offering to view (and\nfetch/push) the changesets in both contexts as equal first citizens.\n\nEven the Git and libxdiff projects, as a concrete example, could\npotentially have benefitted from such a feature: Ideally, it should be\npossible to push commits made in the `xdiff/` directory not only to the\ngit/git repository but also separately from the rest of Git, say, to\nxdiff/libxdiff. This way, the `libxdiff` project would still be able today\nto thrive as an independent project.\n\nThe only way to implement a feature like this that I _can_ think of is to\ngenerate duplicate commit objects, though, with a reference to the \"inner\"\ncommit stored in the \"outer\" commit object. And that strategy breaks down\nreally quickly, no matter whether I think about deep dependency trees or\nabout integrating commit histories that have been made in the \"inner\"\nproject separately and now need to be merged into the \"outer\" project, and\nthere are many more processes for which this strategy strikes me as\ninadequate.\n\nSo yes, I think that the idea per se has a lot of merit in the real world\nout there. It's the implementation details that are an obstacle.\n\nCiao,\nJohannes\n"},{"id":"500808","messageId":"xmqqle105oko.fsf@gitster.g","threadId":"48728","inReplyTo":"8436c2bf-45cf-8009-14cd-c5ca708ece08@gmx.de","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2024-08-13T17:18:15Z","receivedAt":"2024-08-13T17:18:21Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> >> Abusing a long standing bug does not make it a feature. I'm not\n>> >> opposed to having a new option to keep that behavior, but it should\n>> >> not be the default. If you use it that way, you're on your own.\n>> >\n>> > Was such an option ever worked on?\n>>\n>> No.\n>>\n>> I do not recall hearing anybody who have been active in the\n>> development community saying anything good about such an option.\n>> For the past 6 or so years, nobody who actively works on git thought\n>> it was an interesting and/or useful thing to work on.\n>>\n>> I cannot quite say that they thought that it is actively a bad idea\n>> to offer such an option, though.\n>\n> I have encountered the wish quite frequently to be able to make changes in\n> a subdirectory and have them reflected as a commit that is both part of\n> that subdirectory's revision history as well as part of the containing\n> project's.\n\nLet me make sure I understand the above.  You create a commit to\ncontain the change in the submodule and at the same time create a\nnew commit to bind the updated submodule commit to superproject\ntree.  If that is what you are talking about, of course, that would\nbe a nice thing to have.  Sort of \"commit --recursive\".  It is still\ndebatable what to do with the log messages, though (you want to\nleave in the submodule an explanation that is understandable in the\nscope of the submodule, while you want to record in the superproject\na bigger picture reasoning).\n\nBut I did not get the impression that it is what the original poster\nwants.  My reading of the original thread (this is a resurrection of\nan antient thread dating back to 2018) was that you have a submodule\nat path S, you muck with a file in S/file, and you want to commit in\nthe context of the superproject, having the superproject track S/file\nin its history (not just S gitlink).\n\nAnd that is quite different from what you said.\n"},{"id":"500834","messageId":"s5wed6rg5c6.fsf@catalyst.net.nz","threadId":"48728","inReplyTo":"xmqqle105oko.fsf@gitster.g","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Phil Sainty","fromEmail":"phil@catalyst.net.nz","sentAt":"2024-08-13T23:13:25Z","receivedAt":"2024-08-14T03:18:30Z","isPatch":false,"sender":{"key":"phil@catalyst.net.nz","avatar":null},"body":"Junio C Hamano <gitster@pobox.com> writes:\n> Let me make sure I understand the above.  You create a commit to\n> contain the change in the submodule and at the same time create a\n> new commit to bind the updated submodule commit to superproject tree.\n\nI can imagine this ability also being useful, but it would be an\nindependent feature from the one initially requested here...\n\n\n> But I did not get the impression that it is what the original poster\n> wants.  My reading of the original thread (this is a resurrection of\n> an antient thread dating back to 2018) was that you have a submodule\n> at path S, you muck with a file in S/file, and you want to commit in\n> the context of the superproject, having the superproject track S/file\n> in its history (not just S gitlink).\n\nThat's correct.\n\nMy common usage was that I would add the entire contents of S, along\nwith some associated configuration outside of S, and then make a commit\nof all of that in the superproject.\n\nThe two repos (superproject and submodule S) are then tracking the files\nin S independently; so if I was to pull new changes to the submodule\nfrom its own upstream, git commands run from the S directory would not\nshow any changes vs the state of the submodule repo, whereas commands\nrun from the superproject would see new changes.\n\nCloning the superproject repo would produce its version of S, and\nwithout the S/.git directory.\n\n\n-Phil\n"},{"id":"500875","messageId":"24f8477b-03c0-5dd5-99c3-7520ce95376d@gmx.de","threadId":"48728","inReplyTo":"s5wed6rg5c6.fsf@catalyst.net.nz","subject":"Re: Adding nested repository with slash adds files instead of gitlink","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2024-08-14T12:00:55Z","receivedAt":"2024-08-14T12:01:20Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Phil & Junio,\n\nOn Wed, 14 Aug 2024, Phil Sainty wrote:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n> > Let me make sure I understand the above.  You create a commit to\n> > contain the change in the submodule and at the same time create a\n> > new commit to bind the updated submodule commit to superproject tree.\n>\n> I can imagine this ability also being useful, but it would be an\n> independent feature from the one initially requested here...\n\nFWIW I did not intend to suggest anything to do with submodules.\n\nThere are too many issues with submodules and I don't think they will ever\nbe resolved, as they simply don't integrate into the original, elegant\ndesign of having all Git objects in the same repository.\n\nWhat I had in mind (and which I described only very loosely) was to create\na super-project commit that references the modified subdirectory as part\nof the same project, much like `xdiff/` files are tracked inside git/git.\n\nYes, I papered over the need to create at least one new tree object that\nis derived from the super-project's root tree object and references the\nroot tree object of the \"inner\" commit. I did not want to go into too many\ndetails about the technical implementation, and chose to use the `xdiff/`\nexample as a way to transport my idea, but apparently I was wrong to\nbelieve that it would do a good enough job.\n\nIn essence, what I would love to have is more along the lines of how\nSubversion allows you to check out just a subdirectory of the project, and\nrestrict the revision history to that directory in that checkout.\n\nThis is different from submodules, and also from subtrees, as it would\nallow to treat `xdiff/` as a stand-alone repository, but also allow to\ntreat it as a tracked subdirectory of the super-project at the same time,\nboth equally-well integrated into the standard Git processes like `git log\n-G`, `git bisect`, `git rebase`, etc.\n\n> > But I did not get the impression that it is what the original poster\n> > wants.  My reading of the original thread (this is a resurrection of\n> > an antient thread dating back to 2018) was that you have a submodule\n> > at path S, you muck with a file in S/file, and you want to commit in\n> > the context of the superproject, having the superproject track S/file\n> > in its history (not just S gitlink).\n>\n> That's correct.\n>\n> My common usage was that I would add the entire contents of S, along\n> with some associated configuration outside of S, and then make a commit\n> of all of that in the superproject.\n\nThis could be achieved in a very hacky way by moving the `.git` directory\nof S out of the way, committing, then moving it back, right?\n\n> The two repos (superproject and submodule S) are then tracking the files\n> in S independently; so if I was to pull new changes to the submodule\n> from its own upstream, git commands run from the S directory would not\n> show any changes vs the state of the submodule repo, whereas commands\n> run from the superproject would see new changes.\n\nI did indeed have a more integrated thing in mind, where the commits of\nthe super-project that touch S and the commits of S were more connected.\n\nCiao,\nJohannes\n\n> Cloning the superproject repo would produce its version of S, and\n> without the S/.git directory.\n"}]}