{"thread":{"id":"55183","subject":"[QUESTION] Tracking HEAD changes?","startedAt":"2021-02-22T09:14:48Z","lastAt":"2021-03-01T10:03:59Z","messageCount":15,"participants":["Yaron Wittenstein","Jeff King","Patrick Steinhardt","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"417465","messageId":"CAGgn8PdU1GE_CZdGUpJWKzygd0O+Yn2BnAFGmPfKAxFpoVoqUA@mail.gmail.com","threadId":"55183","inReplyTo":null,"subject":"[QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-02-22T09:12:11Z","receivedAt":"2021-02-22T09:14:48Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"Hi,\n\nIs there any possible way to track changes to HEAD using hooks?\n\nBeing able to listen using hooks to events such as pre-head-checkout\nand post-head-checkout would be the best option (from my perspective).\n\nTo my knowledge, the only possible way to do that today is by adding a\nfile watch over the refs directory.\n\nThank you!\n    Yaron\n"},{"id":"417511","messageId":"YDROhhrM5qJti1ir@coredump.intra.peff.net","threadId":"55183","inReplyTo":"CAGgn8PdU1GE_CZdGUpJWKzygd0O+Yn2BnAFGmPfKAxFpoVoqUA@mail.gmail.com","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-23T00:38:30Z","receivedAt":"2021-02-23T00:39:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 22, 2021 at 11:12:11AM +0200, Yaron Wittenstein wrote:\n\n> Is there any possible way to track changes to HEAD using hooks?\n> \n> Being able to listen using hooks to events such as pre-head-checkout\n> and post-head-checkout would be the best option (from my perspective).\n> \n> To my knowledge, the only possible way to do that today is by adding a\n> file watch over the refs directory.\n\nNo, I don't think there is currently a better way.\n\nIf you do go the file watch route, make sure you put one on HEAD, too\n(to catch the case of checking out a different branch, as opposed to\nupdating it with a new commit). I use:\n\n  gitdir=$(git rev-parse --git-dir)\n  # We need delete_self to pick up changes to HEAD (since it gets renamed\n  # over), and \"move\" to pick up changes in the refs directories.\n  inotifywait -qq -t 60 -e delete_self -e move -r \"$gitdir/HEAD\" \"$gitdir/refs\"\n\nin a script that I use for automatically running tests against the\ncurrent commit. (if you are doing something similar, I also recommend\nhttps://github.com/mhagger/git-test for avoiding re-running against the\nsame commits repeatedly).\n\n-Peff\n"},{"id":"417618","messageId":"YDVo0kGYODP0JjqT@coredump.intra.peff.net","threadId":"55183","inReplyTo":"YDROhhrM5qJti1ir@coredump.intra.peff.net","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-23T20:42:58Z","receivedAt":"2021-02-23T20:44:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 22, 2021 at 07:38:30PM -0500, Jeff King wrote:\n\n> On Mon, Feb 22, 2021 at 11:12:11AM +0200, Yaron Wittenstein wrote:\n> \n> > Is there any possible way to track changes to HEAD using hooks?\n> > \n> > Being able to listen using hooks to events such as pre-head-checkout\n> > and post-head-checkout would be the best option (from my perspective).\n> > \n> > To my knowledge, the only possible way to do that today is by adding a\n> > file watch over the refs directory.\n> \n> No, I don't think there is currently a better way.\n\nActually, I completely forgot about Patrick's recent ref-transaction\nhook. See the \"reference-transaction\" section of githooks(7). They do\nmore than you'd need, but you should be able to write a hook that just\nlooks for updates to HEAD, or updates to the ref that HEAD is pointing\nat.\n\nThe code was introduced in 6754159767 (refs: implement reference\ntransaction hook, 2020-06-19), so you'll need Git v2.28.0 or later.\n\n-Peff\n"},{"id":"417754","messageId":"CAGgn8PcPtLNtZTmMqKKTmH3KOezkr-jY7aTEDA-0dvYWuzid9A@mail.gmail.com","threadId":"55183","inReplyTo":"YDVo0kGYODP0JjqT@coredump.intra.peff.net","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-02-24T20:21:55Z","receivedAt":"2021-02-24T20:23:15Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"That indeed seems to do the trick.\nI've done a little experiment and saw that when doing git reset the\nhook gets called.\n\nHowever, when switching branches the hook doesn't execute :(\n\nI don't understand if it's intentional, since when I've moved to a new\nbranch HEAD pointed to another commit id.\nThe only workaround I see here is using the post-checkout hook in addition.\n\nThank you very much for helping me. I really appreciate it!!\n     Yaron\n\nOn Tue, Feb 23, 2021 at 10:42 PM Jeff King <peff@peff.net> wrote:\n>\n> On Mon, Feb 22, 2021 at 07:38:30PM -0500, Jeff King wrote:\n>\n> > On Mon, Feb 22, 2021 at 11:12:11AM +0200, Yaron Wittenstein wrote:\n> >\n> > > Is there any possible way to track changes to HEAD using hooks?\n> > >\n> > > Being able to listen using hooks to events such as pre-head-checkout\n> > > and post-head-checkout would be the best option (from my perspective).\n> > >\n> > > To my knowledge, the only possible way to do that today is by adding a\n> > > file watch over the refs directory.\n> >\n> > No, I don't think there is currently a better way.\n>\n> Actually, I completely forgot about Patrick's recent ref-transaction\n> hook. See the \"reference-transaction\" section of githooks(7). They do\n> more than you'd need, but you should be able to write a hook that just\n> looks for updates to HEAD, or updates to the ref that HEAD is pointing\n> at.\n>\n> The code was introduced in 6754159767 (refs: implement reference\n> transaction hook, 2020-06-19), so you'll need Git v2.28.0 or later.\n>\n> -Peff\n"},{"id":"417761","messageId":"YDa/EupbrNa62r+D@coredump.intra.peff.net","threadId":"55183","inReplyTo":"CAGgn8PcPtLNtZTmMqKKTmH3KOezkr-jY7aTEDA-0dvYWuzid9A@mail.gmail.com","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-24T21:03:14Z","receivedAt":"2021-02-24T21:03:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Feb 24, 2021 at 10:21:55PM +0200, Yaron Wittenstein wrote:\n\n> That indeed seems to do the trick.\n> I've done a little experiment and saw that when doing git reset the\n> hook gets called.\n> \n> However, when switching branches the hook doesn't execute :(\n> \n> I don't understand if it's intentional, since when I've moved to a new\n> branch HEAD pointed to another commit id.\n> The only workaround I see here is using the post-checkout hook in addition.\n\nHmm, I would have thought that the branch switch would trigger the hooks\nbecause they're updating HEAD. I wonder if that is a bug (or lack of\nfeature :) ) in the transaction hooks, or something Patrick did\nintentionally.\n\n-Peff\n"},{"id":"417786","messageId":"YDc3dinQ37FY8fhD@ncase","threadId":"55183","inReplyTo":"YDa/EupbrNa62r+D@coredump.intra.peff.net","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2021-02-25T05:36:54Z","receivedAt":"2021-02-25T05:39:07Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 24, 2021 at 04:03:14PM -0500, Jeff King wrote:\n> On Wed, Feb 24, 2021 at 10:21:55PM +0200, Yaron Wittenstein wrote:\n> \n> > That indeed seems to do the trick.\n> > I've done a little experiment and saw that when doing git reset the\n> > hook gets called.\n> > \n> > However, when switching branches the hook doesn't execute :(\n> > \n> > I don't understand if it's intentional, since when I've moved to a new\n> > branch HEAD pointed to another commit id.\n> > The only workaround I see here is using the post-checkout hook in addition.\n> \n> Hmm, I would have thought that the branch switch would trigger the hooks\n> because they're updating HEAD. I wonder if that is a bug (or lack of\n> feature :) ) in the transaction hooks, or something Patrick did\n> intentionally.\n> \n> -Peff\n\nIt was done semi-intentionally, or at least with the knowledge that\nsymrefs aren't covered. This is mostly because they're not covered by\nthe reference transaction mechanism itself.\n\nBut this again reminds me that I still have to update the documentation\nof the hook to at least make it more explicit what's currently covered\nand what's not.\n\nPatrick\n"},{"id":"417789","messageId":"CAGgn8PfdGBuB29Gxba6OmhSagjqwH2DNUv9XyJnXUhcKpJZBsA@mail.gmail.com","threadId":"55183","inReplyTo":"YDc3dinQ37FY8fhD@ncase","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-02-25T06:01:11Z","receivedAt":"2021-02-25T06:07:00Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"Thank you for the clarification!\n\nIs there any plan to support such a case in the future?\n\nAlso, I've observed that the \"post-index-change\" hook is being\ntriggered before calling the \"reference-transaction\" hook (with the\n\"prepared\" state).\nIt seems not intuitive to me since the index and working dirs are\nbeing updated before approving the transaction.\n(the HEAD still points to an \"old\" reference while the\n\"post-index-change\" hook is executing).\n\nThank you,\n   Yaron\n\nOn Thu, Feb 25, 2021 at 7:37 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Wed, Feb 24, 2021 at 04:03:14PM -0500, Jeff King wrote:\n> > On Wed, Feb 24, 2021 at 10:21:55PM +0200, Yaron Wittenstein wrote:\n> >\n> > > That indeed seems to do the trick.\n> > > I've done a little experiment and saw that when doing git reset the\n> > > hook gets called.\n> > >\n> > > However, when switching branches the hook doesn't execute :(\n> > >\n> > > I don't understand if it's intentional, since when I've moved to a new\n> > > branch HEAD pointed to another commit id.\n> > > The only workaround I see here is using the post-checkout hook in addition.\n> >\n> > Hmm, I would have thought that the branch switch would trigger the hooks\n> > because they're updating HEAD. I wonder if that is a bug (or lack of\n> > feature :) ) in the transaction hooks, or something Patrick did\n> > intentionally.\n> >\n> > -Peff\n>\n> It was done semi-intentionally, or at least with the knowledge that\n> symrefs aren't covered. This is mostly because they're not covered by\n> the reference transaction mechanism itself.\n>\n> But this again reminds me that I still have to update the documentation\n> of the hook to at least make it more explicit what's currently covered\n> and what's not.\n>\n> Patrick\n"},{"id":"417791","messageId":"YDdDUILUUXA1ytva@ncase","threadId":"55183","inReplyTo":"CAGgn8PfdGBuB29Gxba6OmhSagjqwH2DNUv9XyJnXUhcKpJZBsA@mail.gmail.com","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2021-02-25T06:27:28Z","receivedAt":"2021-02-25T06:28:44Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Thu, Feb 25, 2021 at 08:01:11AM +0200, Yaron Wittenstein wrote:\n> Thank you for the clarification!\n> \n> Is there any plan to support such a case in the future?\n\nI personally don't have any plans to do so, but I can see usecases where\nit would make sense. So I wouldn't be opposing any such efforts either.\n\n> Also, I've observed that the \"post-index-change\" hook is being\n> triggered before calling the \"reference-transaction\" hook (with the\n> \"prepared\" state). It seems not intuitive to me since the index and\n> working dirs are being updated before approving the transaction. (the\n> HEAD still points to an \"old\" reference while the \"post-index-change\"\n> hook is executing).\n\nThis is something that cannot really be helped though. The\nreference-transaction hook directly hooks into the reference transaction\nmechanism, which is how git updates all references. So we do not really\nhave any control over when the hook will get executed: it will simply\nget executed whenever the reference transaction itself gets prepared\n(refs get locked) and committed (written updated refs got moved into\nplace).\n\nAnd that's by design: my objective was to catch _all_ reference updates\nsuch that one can coordinate across multiple git nodes which all perform\nthe same action to assert they're moving from the same state to the same\nstate, regardless of whether they're doing a git-push(1), git-merge(1)\nor git-update-ref(1).\n\nSo what you're observing is simply mirroring \"reality\": the order in\nwhich git does its things here. There can be arbitrarily many\ntransactions in a given git command, and the only way this can be\nchanged is by changing how the command operating the transcations works.\n\nPatrick\n\n> Thank you,\n>    Yaron\n> \n> On Thu, Feb 25, 2021 at 7:37 AM Patrick Steinhardt <ps@pks.im> wrote:\n> >\n> > On Wed, Feb 24, 2021 at 04:03:14PM -0500, Jeff King wrote:\n> > > On Wed, Feb 24, 2021 at 10:21:55PM +0200, Yaron Wittenstein wrote:\n> > >\n> > > > That indeed seems to do the trick.\n> > > > I've done a little experiment and saw that when doing git reset the\n> > > > hook gets called.\n> > > >\n> > > > However, when switching branches the hook doesn't execute :(\n> > > >\n> > > > I don't understand if it's intentional, since when I've moved to a new\n> > > > branch HEAD pointed to another commit id.\n> > > > The only workaround I see here is using the post-checkout hook in addition.\n> > >\n> > > Hmm, I would have thought that the branch switch would trigger the hooks\n> > > because they're updating HEAD. I wonder if that is a bug (or lack of\n> > > feature :) ) in the transaction hooks, or something Patrick did\n> > > intentionally.\n> > >\n> > > -Peff\n> >\n> > It was done semi-intentionally, or at least with the knowledge that\n> > symrefs aren't covered. This is mostly because they're not covered by\n> > the reference transaction mechanism itself.\n> >\n> > But this again reminds me that I still have to update the documentation\n> > of the hook to at least make it more explicit what's currently covered\n> > and what's not.\n> >\n> > Patrick\n"},{"id":"417795","messageId":"xmqqim6gwrf8.fsf@gitster.g","threadId":"55183","inReplyTo":"YDdDUILUUXA1ytva@ncase","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-02-25T07:13:47Z","receivedAt":"2021-02-25T07:15:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> So what you're observing is simply mirroring \"reality\": the order in\n> which git does its things here. There can be arbitrarily many\n> transactions in a given git command, and the only way this can be\n> changed is by changing how the command operating the transcations works.\n\nIn other words, ref transaction is only about changes to the refs.\nThere is no such \"transaction\" that treats a series of operations\nlike object creation and index manipulation that may happen before a\ngroup of refs are updated as a single unit and make it atomic.\n\n"},{"id":"417798","messageId":"YDdRgwwuvZBGuSVP@ncase","threadId":"55183","inReplyTo":"xmqqim6gwrf8.fsf@gitster.g","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2021-02-25T07:28:03Z","receivedAt":"2021-02-25T07:28:59Z","isPatch":false,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Feb 24, 2021 at 11:13:47PM -0800, Junio C Hamano wrote:\n> Patrick Steinhardt <ps@pks.im> writes:\n> \n> > So what you're observing is simply mirroring \"reality\": the order in\n> > which git does its things here. There can be arbitrarily many\n> > transactions in a given git command, and the only way this can be\n> > changed is by changing how the command operating the transcations works.\n> \n> In other words, ref transaction is only about changes to the refs.\n> There is no such \"transaction\" that treats a series of operations\n> like object creation and index manipulation that may happen before a\n> group of refs are updated as a single unit and make it atomic.\n\nExactly. Thanks for putting it into better words than I did.\n\nPatrick\n"},{"id":"417803","messageId":"CAGgn8PfnWQRy_ovN29RfMH7cyP62y67uStD2cGUwgr4_ovLuOw@mail.gmail.com","threadId":"55183","inReplyTo":"YDdRgwwuvZBGuSVP@ncase","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-02-25T07:50:06Z","receivedAt":"2021-02-25T07:51:29Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"Thank you all!\n\nI'd like to make sure I understand the way things are right now:\n\n1. The reference-transaction hook as it's today doesn't intercept\nsymbolic-references changes.\nIt means that when HEAD changes due to branch-switching the hook won't\nget called.\n\nAre there any other cases that today the transaction won't execute? (I\ncouldn't think of one)\n\n2. The mechanisms that handle the changes to index and working-dir are\nisolated from the one that manages the refs updates.\n\nA side-effect to that is the post-index-change hook running before the\nreference-transaction one.\nFuture code changes to the way git operates could result in the\nreference-transaction hook running before the post-index-change one.\n\nIs that correct?\n\n  Thank you!\n      Yaron\n\nOn Thu, Feb 25, 2021 at 9:28 AM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Wed, Feb 24, 2021 at 11:13:47PM -0800, Junio C Hamano wrote:\n> > Patrick Steinhardt <ps@pks.im> writes:\n> >\n> > > So what you're observing is simply mirroring \"reality\": the order in\n> > > which git does its things here. There can be arbitrarily many\n> > > transactions in a given git command, and the only way this can be\n> > > changed is by changing how the command operating the transcations works.\n> >\n> > In other words, ref transaction is only about changes to the refs.\n> > There is no such \"transaction\" that treats a series of operations\n> > like object creation and index manipulation that may happen before a\n> > group of refs are updated as a single unit and make it atomic.\n>\n> Exactly. Thanks for putting it into better words than I did.\n>\n> Patrick\n"},{"id":"417868","messageId":"YDiOXDbN/JtUWgWu@coredump.intra.peff.net","threadId":"55183","inReplyTo":"YDc3dinQ37FY8fhD@ncase","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-02-26T05:59:56Z","receivedAt":"2021-02-26T06:00:58Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Feb 25, 2021 at 06:36:54AM +0100, Patrick Steinhardt wrote:\n\n> > Hmm, I would have thought that the branch switch would trigger the hooks\n> > because they're updating HEAD. I wonder if that is a bug (or lack of\n> > feature :) ) in the transaction hooks, or something Patrick did\n> > intentionally.\n> \n> It was done semi-intentionally, or at least with the knowledge that\n> symrefs aren't covered. This is mostly because they're not covered by\n> the reference transaction mechanism itself.\n\nAh, right, I forgot about that. That might be something that we'd want\nto fix if anybody wanted to use the transaction hooks to track the\ncomplete state of refs.\n\nAt GitHub, our repository replication does track symbolic ref updates,\nbut we handle it outside of Git. Our normal ref updates use a few custom\nbits of code similar to your transaction hooks in order to implement a\n3-phase commit. But our symref updates don't; they just take a lock, run\ngit-symbolic-ref on each, and then vote on the result. This is slower\nand less robust, but symbolic ref updates are relatively rare, so it\nhasn't been a big deal.\n\n-Peff\n"},{"id":"417913","messageId":"CAGgn8PdYsfbSE2vRunOXO1JqXoM8LxoD+5Zn74jmb9vpqDXh+Q@mail.gmail.com","threadId":"55183","inReplyTo":"YDiOXDbN/JtUWgWu@coredump.intra.peff.net","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-02-26T20:58:37Z","receivedAt":"2021-02-26T20:59:57Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"Thank you all!\n\nI'd like to make sure I understand the way things are right now:\n\n1. The reference-transaction hook as it's today doesn't intercept\nsymbolic-references changes. It means that when HEAD changes due to\nbranch-switching the hook won't\nget called.\n\nAre there any other cases that today the transaction won't execute? (I\ncouldn't think of one)\n\n2. The mechanisms that handle the changes to index and working-dir are\nisolated from the one that manages the refs updates.\n\nA side-effect to that is the post-index-change hook running before the\nreference-transaction one.\nFuture code changes to the way git operates could result in the\nreference-transaction hook running before the post-index-change one.\n\nIs that correct?\n\n  Thank you!\n      Yaron\n\nOn Fri, Feb 26, 2021 at 7:59 AM Jeff King <peff@peff.net> wrote:\n>\n> On Thu, Feb 25, 2021 at 06:36:54AM +0100, Patrick Steinhardt wrote:\n>\n> > > Hmm, I would have thought that the branch switch would trigger the hooks\n> > > because they're updating HEAD. I wonder if that is a bug (or lack of\n> > > feature :) ) in the transaction hooks, or something Patrick did\n> > > intentionally.\n> >\n> > It was done semi-intentionally, or at least with the knowledge that\n> > symrefs aren't covered. This is mostly because they're not covered by\n> > the reference transaction mechanism itself.\n>\n> Ah, right, I forgot about that. That might be something that we'd want\n> to fix if anybody wanted to use the transaction hooks to track the\n> complete state of refs.\n>\n> At GitHub, our repository replication does track symbolic ref updates,\n> but we handle it outside of Git. Our normal ref updates use a few custom\n> bits of code similar to your transaction hooks in order to implement a\n> 3-phase commit. But our symref updates don't; they just take a lock, run\n> git-symbolic-ref on each, and then vote on the result. This is slower\n> and less robust, but symbolic ref updates are relatively rare, so it\n> hasn't been a big deal.\n>\n> -Peff\n"},{"id":"418016","messageId":"YDyt6h3dphnG8kwk@coredump.intra.peff.net","threadId":"55183","inReplyTo":"CAGgn8PdYsfbSE2vRunOXO1JqXoM8LxoD+5Zn74jmb9vpqDXh+Q@mail.gmail.com","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-03-01T09:03:38Z","receivedAt":"2021-03-01T09:05:44Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Feb 26, 2021 at 10:58:37PM +0200, Yaron Wittenstein wrote:\n\n> I'd like to make sure I understand the way things are right now:\n> \n> 1. The reference-transaction hook as it's today doesn't intercept\n> symbolic-references changes. It means that when HEAD changes due to\n> branch-switching the hook won't\n> get called.\n> \n> Are there any other cases that today the transaction won't execute? (I\n> couldn't think of one)\n\nNo, I don't think so.\n\n> 2. The mechanisms that handle the changes to index and working-dir are\n> isolated from the one that manages the refs updates.\n> \n> A side-effect to that is the post-index-change hook running before the\n> reference-transaction one.\n> Future code changes to the way git operates could result in the\n> reference-transaction hook running before the post-index-change one.\n> \n> Is that correct?\n\nYes, that matches my understanding.\n\n-Peff\n"},{"id":"418024","messageId":"CAGgn8Pcnxu6vQbkpgBf=A-tBdhP5npne-dZpFv9MzdEUuuRYgQ@mail.gmail.com","threadId":"55183","inReplyTo":"YDyt6h3dphnG8kwk@coredump.intra.peff.net","subject":"Re: [QUESTION] Tracking HEAD changes?","fromName":"Yaron Wittenstein","fromEmail":"yaron.wittenstein@gmail.com","sentAt":"2021-03-01T10:02:05Z","receivedAt":"2021-03-01T10:03:59Z","isPatch":false,"sender":{"key":"yaron.wittenstein@gmail.com","avatar":"https://gravatar.com/avatar/1b7353d1cee7abf7e71db21ceeebe59e00c15845547454cf061bcfa544afbffb?d=mp&s=160"},"body":"Cool, thanks!\n\nOn Mon, Mar 1, 2021 at 11:03 AM Jeff King <peff@peff.net> wrote:\n>\n> On Fri, Feb 26, 2021 at 10:58:37PM +0200, Yaron Wittenstein wrote:\n>\n> > I'd like to make sure I understand the way things are right now:\n> >\n> > 1. The reference-transaction hook as it's today doesn't intercept\n> > symbolic-references changes. It means that when HEAD changes due to\n> > branch-switching the hook won't\n> > get called.\n> >\n> > Are there any other cases that today the transaction won't execute? (I\n> > couldn't think of one)\n>\n> No, I don't think so.\n>\n> > 2. The mechanisms that handle the changes to index and working-dir are\n> > isolated from the one that manages the refs updates.\n> >\n> > A side-effect to that is the post-index-change hook running before the\n> > reference-transaction one.\n> > Future code changes to the way git operates could result in the\n> > reference-transaction hook running before the post-index-change one.\n> >\n> > Is that correct?\n>\n> Yes, that matches my understanding.\n>\n> -Peff\n"}]}