{"thread":{"id":"31380","subject":"dangling submodule references after rebase","startedAt":"2012-08-29T09:55:04Z","lastAt":"2012-08-29T20:19:09Z","messageCount":2,"participants":["Stijn Souffriau","Jens Lehmann"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"198035","messageId":"503DE6F8.3030106@essensium.com","threadId":"31380","inReplyTo":null,"subject":"dangling submodule references after rebase","fromName":"Stijn Souffriau","fromEmail":"stijn.souffriau@essensium.com","sentAt":"2012-08-29T09:55:04Z","receivedAt":"2012-08-29T09:55:04Z","isPatch":false,"sender":{"key":"stijn.souffriau@essensium.com","avatar":null},"body":"Hi all,\n\nI am using a repository that has a sub module which is being committed \nto frequently by myself as well as others. Because of the heavy \nconcurrent development I need to do a lot of rebasing. Since the sub \nmodule commit hashes referenced by the parent repository can become \ndangling as a result of rebasing the sub module I am required to do lots \nof manual \"fixing\" of the references in the parent repository using an \ninteractive rebase. This is a tedious, error-prone procedure which I \nwould like to automate.\n\nI was wondering if anyone has thought about solving this problem yet in \nthe past and what might be a good solution?\n\nI was thinking something along the lines of extending the add and commit \ncommands so that a parent repository would signal to the sub modules \nthat it's index or some if it's commits reference certain sub module \ncommits; and also the rebase command so that it would update the parent \nrepository commits with new hashes using the information stored by the \nadd or commit commands. The procedure would have to be made recursive \nbecause changing commits in the parent repository might also require \nchanging commits in it's parent repository as well.\n\nI'm still no quite sure for which sub module rebase operations the \nreferencing parent repository commits would actually have to be \n\"updated\". The reason being that the rebased commits might still be \nreferenced by another branch and so they might continue to exist after \nthe rebase which raises the question if the parent repository commits \nneed to be udated or not. I think this question would have to be \nanswered by the add and commit commands which would also have to specify \na referenced branch in addition to referenced commits so that the parent \nrepo commits would only have to be updated if the commits on this branch \nare rebased. By default this could be the branch checked out in the sub \nmodule at the time the referencing commit was made.\n\nFor obvious reasons this should only be done for newly made, unpushed \nand unpulled commits in the repository. However, it might be interesting \nto also enable people to manually bind a parent repo commits to a \nsubmodule branch so that the commits in this parent repo branch are \nupdated when the sub module branch is rebased.\n\nI would like see this end up in the mainline and so I'm very interested \nin your opinions.\n\nThanks,\n\nStijn\n"},{"id":"198057","messageId":"503E793D.4080305@web.de","threadId":"31380","inReplyTo":"503DE6F8.3030106@essensium.com","subject":"Re: dangling submodule references after rebase","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2012-08-29T20:19:09Z","receivedAt":"2012-08-29T20:19:09Z","isPatch":false,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 29.08.2012 11:55, schrieb Stijn Souffriau:\n> I am using a repository that has a sub module which is being committed to frequently by myself as well as others. Because of the heavy concurrent development I need to do a lot of rebasing. Since the sub module commit hashes referenced by the parent repository can become dangling as a result of rebasing the sub module I am required to do lots of manual \"fixing\" of the references in the parent repository using an interactive rebase. This is a tedious, error-prone procedure which I would like to automate.\n\nI am very interested to hear how you intend to do that. I can't think of\na sane way to do that but would really like to be convinced otherwise.\n\n> I was wondering if anyone has thought about solving this problem yet in the past and what might be a good solution?\n\nWe don't solve this problem, but try to avoid it by having the best\npractice that only commits which are on (or merged into) a stable branch\nin the submodule may be committed on a branch in the superproject. This\nworks really well for us.\n\n> I was thinking something along the lines of extending the add and commit commands so that a parent repository would signal to the sub modules that it's index or some if it's commits reference certain sub module commits; and also the rebase command so that it would update the parent repository commits with new hashes using the information stored by the add or commit commands. The procedure would have to be made recursive because changing commits in the parent repository might also require changing commits in it's parent repository as well.\n\nSubmodules aren't aware that they have a superproject (which is a feature),\nso maybe you could issue something like a \"rebase that branch in the\nsubmodule and update all commits in this branch here referencing those\nrebased commits\" in the topmost superproject and iterate down from there.\n\n> I'm still no quite sure for which sub module rebase operations the referencing parent repository commits would actually have to be \"updated\".\n\nMe thinks it could make sense to have a branch in the superproject which\nfollows the development in the submodule, which would answer what commits\nyou'd have to check.\n\n> The reason being that the rebased commits might still be referenced by another branch and so they might continue to exist after the rebase which raises the question if the parent repository commits need to be udated or not. I think this question would have to be answered by the add and commit commands which would also have to specify a referenced branch in addition to referenced commits so that the parent repo commits would only have to be updated if the commits on this branch are rebased. By default this could be the branch checked out in the sub module at the time the\n> referencing commit was made.\n\nAnd the distributed nature of git leaves plenty of room to have other\nbranches in other repos referencing the commits you just rebased. And for\nlots of submodules there is more than a single superproject, making that\nproblem even more interesting.\n\n> For obvious reasons this should only be done for newly made, unpushed and unpulled commits in the repository.\n\nSo that would make this operation impossible once you pushed a submodule\nbranch e.g. just to back it up on the server? I think that would make\nthis much less useful. When you rewrite history in a submodule you always\nhave the potential problem of removing the commits used by another branch\nin your repo, somebody else's copy of the repo or even in a completely\ndifferent superproject, so you'll have to be careful there anyway.\n\n> However, it might be interesting to also enable people to manually bind a parent repo commits to a submodule branch so that the commits in this parent repo branch are updated when the sub module branch is rebased.\n> \n> I would like see this end up in the mainline and so I'm very interested in your opinions.\n\nI think it the first step should be to line out the solution and then\ncreate one or more scripts demonstrating how that approach could work.\nThen we can decide how to move on from there.\n"}]}