{"thread":{"id":"22498","subject":"Reacting to new commits in a poll-mirror","startedAt":"2010-02-02T22:02:34Z","lastAt":"2010-02-03T10:48:57Z","messageCount":4,"participants":["martin f krafft","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"133406","messageId":"20100202220234.GA17107@lapse.rw.madduck.net","threadId":"22498","inReplyTo":null,"subject":"Reacting to new commits in a poll-mirror","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-02-02T22:02:34Z","receivedAt":"2010-02-02T22:02:34Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Folks,\n\nI am trying to set up Patchwork-Git integration on host A for\na project whose Git repo is on host B. I thought I could use\na mirror (git clone --mirror) on A and regularly fetch from B, but\nI cannot find a way (hook) to make Git on A react to new commits it\nfetched from B.\n\nI can probably hack something up, e.g. store refs before a fetch and\nthen iterate the refs between the stored refs and the HEAD, but this\nseems exceedingly hackish and I'd much rather have this information\nfrom git-fetch (like git-push calls post-receive).\n\nIs this at all possible?\nWould it be possible?\nWhere would this be done?\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \nthe uncertainty principle:\n  you can never be sure how many\n  beers you had last night.\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"133432","messageId":"20100203011050.GA23249@lapse.rw.madduck.net","threadId":"22498","inReplyTo":"20100202220234.GA17107@lapse.rw.madduck.net","subject":"Re: Reacting to new commits in a poll-mirror","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-02-03T01:10:50Z","receivedAt":"2010-02-03T01:10:50Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach martin f krafft <madduck@madduck.net> [2010.02.03.1102 +1300]:\n> I am trying to set up Patchwork-Git integration on host A for\n> a project whose Git repo is on host B. I thought I could use\n> a mirror (git clone --mirror) on A and regularly fetch from B, but\n> I cannot find a way (hook) to make Git on A react to new commits it\n> fetched from B.\n\nOne way is to have a mirror on A, as well as a second repo: first,\nfetch to synchronise the mirror, the push to the second repo, where\nthe post-receive hook will get executed. Works, but it's hackish.\nI'd much rather have hooks react right away to the fetch.\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \n\"life is what happens to you while you're busy making other plans.\"\n                                                        -- john lennon\n \nspamtraps: madduck.bogus@madduck.net\n"},{"id":"133434","messageId":"7vzl3rt88c.fsf@alter.siamese.dyndns.org","threadId":"22498","inReplyTo":"20100203011050.GA23249@lapse.rw.madduck.net","subject":"Re: Reacting to new commits in a poll-mirror","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-02-03T01:32:03Z","receivedAt":"2010-02-03T01:32:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"martin f krafft <madduck@madduck.net> writes:\n\n> also sprach martin f krafft <madduck@madduck.net> [2010.02.03.1102 +1300]:\n>> I am trying to set up Patchwork-Git integration on host A for\n>> a project whose Git repo is on host B. I thought I could use\n>> a mirror (git clone --mirror) on A and regularly fetch from B, but\n>> I cannot find a way (hook) to make Git on A react to new commits it\n>> fetched from B.\n>\n> One way is to have a mirror on A, as well as a second repo: first,\n> fetch to synchronise the mirror, the push to the second repo, where\n> the post-receive hook will get executed. Works, but it's hackish.\n> I'd much rather have hooks react right away to the fetch.\n\nSorry, but I don't understand the motivation.\n\nYou are the one with a desire to know \"what new things I got by 'git\nfetch' I am going to run right now\".\n\nAnd most importantly, that \"right now\" is under complete control of you.\n\nUnlike post-receive hook that was invented as a way to be triggered by an\naction done by somebody else, iow, an action you (the hook owner) do not\ncontrol at all, you do not need any hook around fetch to do what you are\ntrying to do.  You know when you run fetch.  You are the only one who\nupdates that repository A.  Until you decide to fetch, nothing will change\nin the repository A.\n\nSo I don't see what you find wrong about writing your script like:\n\n    #!/bin/sh\n    before_fetch=$(git for-each-ref --format='%(objectname)') &&\n    git fetch || exit\n\n    git rev-list --all --not $before_fetch |\n    while read rev\n    do\n\tdo your patchwork magic...\n    done\n\nIt seems (at least to me) to be exactly the way git plumbing layer was\ndesigned to be used.\n"},{"id":"133464","messageId":"20100203104857.GC20450@lapse.rw.madduck.net","threadId":"22498","inReplyTo":"7vzl3rt88c.fsf@alter.siamese.dyndns.org","subject":"Re: Reacting to new commits in a poll-mirror","fromName":"martin f krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-02-03T10:48:57Z","receivedAt":"2010-02-03T10:48:57Z","isPatch":false,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"also sprach Junio C Hamano <gitster@pobox.com> [2010.02.03.1432 +1300]:\n> So I don't see what you find wrong about writing your script like:\n> \n>     #!/bin/sh\n>     before_fetch=$(git for-each-ref --format='%(objectname)') &&\n>     git fetch || exit\n> \n>     git rev-list --all --not $before_fetch |\n>     while read rev\n>     do\n> \tdo your patchwork magic...\n>     done\n\nThis sounds pretty much what I had in mind, and you have convinced\nme that this is the right/better approach. Thanks for keeping those\nfeet on the ground!\n\n-- \nmartin | http://madduck.net/ | http://two.sentenc.es/\n \nhalf a bee, philosophically, must ipso facto half not be.\nbut half the bee has got to be, vis-a-vis its entity. you see?\nbut can a bee be said to be or not to be an entire bee,\nwhen half the bee is not a bee, due to some ancient injury?\n                                                       -- monty python\n \nspamtraps: madduck.bogus@madduck.net\n"}]}