{"thread":{"id":"60759","subject":"How to execute a command on git am/rebase/cherry pick --abort ?","startedAt":"2024-01-18T12:53:30Z","lastAt":"2024-01-29T14:40:52Z","messageCount":5,"participants":["Konstantin Kharlamov","Patrick Steinhardt"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"486972","messageId":"d66ef46827fc7391bd74ece943afa2c5245896d6.camel@yandex.ru","threadId":"60759","inReplyTo":null,"subject":"How to execute a command on git am/rebase/cherry pick --abort ?","fromName":"Konstantin Kharlamov","fromEmail":"hi-angel@yandex.ru","sentAt":"2024-01-18T12:53:21Z","receivedAt":"2024-01-18T12:53:30Z","isPatch":false,"sender":{"key":"hi-angel@yandex.ru","avatar":null},"body":"(please keep me CC'ed, I'm not subscribed)\n\nHello!\n\nThere's a well-known problem of git not fully checking out changes\nwhile doing e.g. `git checkout` and similar commands when you have\nsubmodules. So e.g. if HEAD changes a submodule commit and you do an\ninteractive rebase to HEAD~2, you may be lucky to find a submodule\ncommit change in `git diff` (because if you don't get lucky, you won't\nnotice that and commit the change to the unrelated HEAD~2).\n\nAs a workaround I have a `git submodule update` inside `post-checkout`\nhook.\n\nNow, the problem is I still often finding myself having the wrong\nsubmodule ID, and I tracked down that problem to commands such as\n`am/rebase/cherry-pick --abort` also not updating the submodule, nor\nexecuting `post-checkout`.\n\nI looked through `man githooks` but couldn't find any way to execute a\n`git submodule update` during these aborts.\n\nAny ideas how to fix these?\n"},{"id":"486973","messageId":"Zaknu0nwBucHVJPP@tanuki","threadId":"60759","inReplyTo":"d66ef46827fc7391bd74ece943afa2c5245896d6.camel@yandex.ru","subject":"Re: How to execute a command on git am/rebase/cherry pick --abort ?","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2024-01-18T13:29:31Z","receivedAt":"2024-01-18T13:29:37Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Jan 18, 2024 at 03:53:21PM +0300, Konstantin Kharlamov wrote:\n> (please keep me CC'ed, I'm not subscribed)\n> \n> Hello!\n> \n> There's a well-known problem of git not fully checking out changes\n> while doing e.g. `git checkout` and similar commands when you have\n> submodules. So e.g. if HEAD changes a submodule commit and you do an\n> interactive rebase to HEAD~2, you may be lucky to find a submodule\n> commit change in `git diff` (because if you don't get lucky, you won't\n> notice that and commit the change to the unrelated HEAD~2).\n> \n> As a workaround I have a `git submodule update` inside `post-checkout`\n> hook.\n> \n> Now, the problem is I still often finding myself having the wrong\n> submodule ID, and I tracked down that problem to commands such as\n> `am/rebase/cherry-pick --abort` also not updating the submodule, nor\n> executing `post-checkout`.\n> \n> I looked through `man githooks` but couldn't find any way to execute a\n> `git submodule update` during these aborts.\n> \n> Any ideas how to fix these?\n\nAre you aware of the `submodule.recurse` config? If set, it should cause\ngit-checkout(1) and many other commands to recurse into submodules and\nupdate them accordingly. This should both make your post-checkout hook\nobsolete and should also work with git-cherry-pick(1) et al.\n\nPatrick\n"},{"id":"486974","messageId":"2c996cb7f83466a4ded11f4f581748c82d24b3c3.camel@yandex.ru","threadId":"60759","inReplyTo":"Zaknu0nwBucHVJPP@tanuki","subject":"Re: How to execute a command on git am/rebase/cherry pick --abort ?","fromName":"Konstantin Kharlamov","fromEmail":"hi-angel@yandex.ru","sentAt":"2024-01-18T13:30:56Z","receivedAt":"2024-01-18T13:37:48Z","isPatch":false,"sender":{"key":"hi-angel@yandex.ru","avatar":null},"body":"On Thu, 2024-01-18 at 14:29 +0100, Patrick Steinhardt wrote:\n> On Thu, Jan 18, 2024 at 03:53:21PM +0300, Konstantin Kharlamov wrote:\n> > (please keep me CC'ed, I'm not subscribed)\n> > \n> > Hello!\n> > \n> > There's a well-known problem of git not fully checking out changes\n> > while doing e.g. `git checkout` and similar commands when you have\n> > submodules. So e.g. if HEAD changes a submodule commit and you do\n> > an\n> > interactive rebase to HEAD~2, you may be lucky to find a submodule\n> > commit change in `git diff` (because if you don't get lucky, you\n> > won't\n> > notice that and commit the change to the unrelated HEAD~2).\n> > \n> > As a workaround I have a `git submodule update` inside `post-\n> > checkout`\n> > hook.\n> > \n> > Now, the problem is I still often finding myself having the wrong\n> > submodule ID, and I tracked down that problem to commands such as\n> > `am/rebase/cherry-pick --abort` also not updating the submodule,\n> > nor\n> > executing `post-checkout`.\n> > \n> > I looked through `man githooks` but couldn't find any way to\n> > execute a\n> > `git submodule update` during these aborts.\n> > \n> > Any ideas how to fix these?\n> \n> Are you aware of the `submodule.recurse` config? If set, it should\n> cause\n> git-checkout(1) and many other commands to recurse into submodules\n> and\n> update them accordingly. This should both make your post-checkout\n> hook\n> obsolete and should also work with git-cherry-pick(1) et al.\n> \n> Patrick\n\nOh, this is amazing, thank you! No, I didn't know about it, will use!\n"},{"id":"487525","messageId":"4dd609ae2a33f3729291ff26b40632c8eb5decae.camel@yandex.ru","threadId":"60759","inReplyTo":"Zaknu0nwBucHVJPP@tanuki","subject":"Re: How to execute a command on git am/rebase/cherry pick --abort ?","fromName":"Konstantin Kharlamov","fromEmail":"hi-angel@yandex.ru","sentAt":"2024-01-29T14:35:27Z","receivedAt":"2024-01-29T14:35:35Z","isPatch":false,"sender":{"key":"hi-angel@yandex.ru","avatar":null},"body":"On Thu, 2024-01-18 at 14:29 +0100, Patrick Steinhardt wrote:\n> On Thu, Jan 18, 2024 at 03:53:21PM +0300, Konstantin Kharlamov wrote:\n> > (please keep me CC'ed, I'm not subscribed)\n> > \n> > Hello!\n> > \n> > There's a well-known problem of git not fully checking out changes\n> > while doing e.g. `git checkout` and similar commands when you have\n> > submodules. So e.g. if HEAD changes a submodule commit and you do\n> > an\n> > interactive rebase to HEAD~2, you may be lucky to find a submodule\n> > commit change in `git diff` (because if you don't get lucky, you\n> > won't\n> > notice that and commit the change to the unrelated HEAD~2).\n> > \n> > As a workaround I have a `git submodule update` inside `post-\n> > checkout`\n> > hook.\n> > \n> > Now, the problem is I still often finding myself having the wrong\n> > submodule ID, and I tracked down that problem to commands such as\n> > `am/rebase/cherry-pick --abort` also not updating the submodule,\n> > nor\n> > executing `post-checkout`.\n> > \n> > I looked through `man githooks` but couldn't find any way to\n> > execute a\n> > `git submodule update` during these aborts.\n> > \n> > Any ideas how to fix these?\n> \n> Are you aware of the `submodule.recurse` config? If set, it should\n> cause\n> git-checkout(1) and many other commands to recurse into submodules\n> and\n> update them accordingly. This should both make your post-checkout\n> hook\n> obsolete and should also work with git-cherry-pick(1) et al.\n\nIt doesn't seem to work ☹ I've set it, and now supposed my top commit\nchanges submodule. So I do a `git rebase -i HEAD~2` and \"reword\" the\nprevious commit. After \"reword\"ing is done, git returns me back to HEAD\ncommit and when I execute `git diff` I see the submodule ID changed ☹\n"},{"id":"487526","messageId":"694c9c01947a7a2e67ea225b12112dcccdafbc9a.camel@yandex.ru","threadId":"60759","inReplyTo":"4dd609ae2a33f3729291ff26b40632c8eb5decae.camel@yandex.ru","subject":"Re: How to execute a command on git am/rebase/cherry pick --abort ?","fromName":"Konstantin Kharlamov","fromEmail":"hi-angel@yandex.ru","sentAt":"2024-01-29T14:40:49Z","receivedAt":"2024-01-29T14:40:52Z","isPatch":false,"sender":{"key":"hi-angel@yandex.ru","avatar":null},"body":"On Mon, 2024-01-29 at 17:35 +0300, Konstantin Kharlamov wrote:\n> On Thu, 2024-01-18 at 14:29 +0100, Patrick Steinhardt wrote:\n> > On Thu, Jan 18, 2024 at 03:53:21PM +0300, Konstantin Kharlamov\n> > wrote:\n> > > (please keep me CC'ed, I'm not subscribed)\n> > > \n> > > Hello!\n> > > \n> > > There's a well-known problem of git not fully checking out\n> > > changes\n> > > while doing e.g. `git checkout` and similar commands when you\n> > > have\n> > > submodules. So e.g. if HEAD changes a submodule commit and you do\n> > > an\n> > > interactive rebase to HEAD~2, you may be lucky to find a\n> > > submodule\n> > > commit change in `git diff` (because if you don't get lucky, you\n> > > won't\n> > > notice that and commit the change to the unrelated HEAD~2).\n> > > \n> > > As a workaround I have a `git submodule update` inside `post-\n> > > checkout`\n> > > hook.\n> > > \n> > > Now, the problem is I still often finding myself having the wrong\n> > > submodule ID, and I tracked down that problem to commands such as\n> > > `am/rebase/cherry-pick --abort` also not updating the submodule,\n> > > nor\n> > > executing `post-checkout`.\n> > > \n> > > I looked through `man githooks` but couldn't find any way to\n> > > execute a\n> > > `git submodule update` during these aborts.\n> > > \n> > > Any ideas how to fix these?\n> > \n> > Are you aware of the `submodule.recurse` config? If set, it should\n> > cause\n> > git-checkout(1) and many other commands to recurse into submodules\n> > and\n> > update them accordingly. This should both make your post-checkout\n> > hook\n> > obsolete and should also work with git-cherry-pick(1) et al.\n> \n> It doesn't seem to work ☹ I've set it, and now supposed my top commit\n> changes submodule. So I do a `git rebase -i HEAD~2` and \"reword\" the\n> previous commit. After \"reword\"ing is done, git returns me back to\n> HEAD\n> commit and when I execute `git diff` I see the submodule ID changed ☹\n\nWell, FTR, I just figured out why that happens, but the option being\nbroken still stands.\n\nSo, turns out what happened is that I have `git submodule update` call\nin my `post-checkout` hook, which that `submodule.recurse` option\ndoesn't account for. Unfortunately, if removing it fixes the situation\nmentioned above, however git breaks elsewhere: if I know execute \"edit\"\non the previous commit and use `git diff`, I see the submodule ID in\nthe changes.\n\nSo… I guess my initial question still stands: is there any hook to fix\nthe problem of git not updating the submodule upon `git rebase --abort`\nand co?\n"}]}