{"thread":{"id":"40952","subject":"Post-receive hook for \"git pull\"","startedAt":"2015-12-07T13:47:58Z","lastAt":"2016-02-12T13:39:09Z","messageCount":3,"participants":["Stefan Monnier","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"274110","messageId":"jwv4mful6nu.fsf-monnier+gmane.comp.version-control.git@gnu.org","threadId":"40952","inReplyTo":null,"subject":"Post-receive hook for \"git pull\"","fromName":"Stefan Monnier","fromEmail":"monnier@iro.umontreal.ca","sentAt":"2015-12-07T13:47:58Z","receivedAt":"2015-12-07T13:47:58Z","isPatch":false,"sender":{"key":"monnier@iro.umontreal.ca","avatar":null},"body":"I have a system here where it can be quite common to have thousands of\nbranches in the remote repository, and where I'd like to update some\nlocal state according to the appearance of new branches (or updates of\npre-existing ones).\n\nCurrently, I use a \"git for-each-ref\" after pulling and then check (for\neach one of those refs) if an update is warranted, but this can get slow\nwith that many branches.  Is there some way to get something like the\npost-receive hook to be run for \"git pull\", so that the script gets told\ndirectly which (remote tracking) branches have been modified/created?\n\n\n        Stefan\n"},{"id":"274129","messageId":"xmqqio4am3uk.fsf@gitster.mtv.corp.google.com","threadId":"40952","inReplyTo":"jwv4mful6nu.fsf-monnier+gmane.comp.version-control.git@gnu.org","subject":"Re: Post-receive hook for \"git pull\"","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-12-07T19:54:43Z","receivedAt":"2015-12-07T19:54:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Monnier <monnier@iro.umontreal.ca> writes:\n\n> I have a system here where it can be quite common to have thousands of\n> branches in the remote repository, and where I'd like to update some\n> local state according to the appearance of new branches (or updates of\n> pre-existing ones).\n>\n> Currently, I use a \"git for-each-ref\" after pulling and then check (for\n> each one of those refs) if an update is warranted, but this can get slow\n> with that many branches.  Is there some way to get something like the\n> post-receive hook to be run for \"git pull\", so that the script gets told\n> directly which (remote tracking) branches have been modified/created?\n\nI do not think there is.  But you could easily script along the\nlines of...\n\n    #!/bin/sh\n    git for-each-ref | sort >prestate\n    git pull \"$@\"\n    git for-each-ref | sort >poststate\n    comm -12 prestate poststate\n\n... or something like that, no?\n"},{"id":"278007","messageId":"jwvlh6qt5i6.fsf-monnier+gmane.comp.version-control.git@gnu.org","threadId":"40952","inReplyTo":"xmqqio4am3uk.fsf@gitster.mtv.corp.google.com","subject":"Re: Post-receive hook for \"git pull\"","fromName":"Stefan Monnier","fromEmail":"monnier@iro.umontreal.ca","sentAt":"2016-02-12T13:39:09Z","receivedAt":"2016-02-12T13:39:09Z","isPatch":false,"sender":{"key":"monnier@iro.umontreal.ca","avatar":null},"body":">> I have a system here where it can be quite common to have thousands of\n>> branches in the remote repository, and where I'd like to update some\n>> local state according to the appearance of new branches (or updates of\n>> pre-existing ones).\n>> Currently, I use a \"git for-each-ref\" after pulling and then check (for\n>> each one of those refs) if an update is warranted, but this can get slow\n>> with that many branches.  Is there some way to get something like the\n>> post-receive hook to be run for \"git pull\", so that the script gets told\n>> directly which (remote tracking) branches have been modified/created?\n\n> I do not think there is.  But you could easily script along the\n> lines of...\n\n>     #!/bin/sh\n>     git for-each-ref | sort >prestate\n>     git pull \"$@\"\n>     git for-each-ref | sort >poststate\n>     comm -12 prestate poststate\n\nRight, it kinda works, but it can break down in case of\nconcurrent operations.\n\nI really wish there was a way to get something like the post-receive\nhook to be called everytime new commits are added, regardless if it's\ndue to a push, a pull, a commit, a fast-import, ...\n\n\n        Stefan\n"}]}