Re: git svn and the post-receive hook
Pascal Obry <pascal@obry.net> writes:
> BTW, I do not see why this would be a problem with git-svn whereas the
> post-receive hook is fine for Git.
You probably haven't read Miklos's response have you? post-receive is about what happens at the remote end after you "push" there, and does not have to do with what happens when you fetch.
The article I gave you a link earlier gives a guideline to decide when we choose to add hook for particular step of operation (and when we choose not to). The new call from "git svn rebase" (and presumably "git svn fetch" which is the first step of that operation) needs to be justified.
Having said that, I would have framed your argument in a different way. I suspect then you would not have heard the above objections if you did so:
After pushing to a remote side, there is a post-receive hook so that
some processing can happen depending on which refs changed from what
commit to what new commit. This is primarily because "push" goes to
the remote side and the user may not have any other means to trigger an
operation over there (e.g. there may not be ssh login access, just
git-shell running to accept pushes).
After fetching from somewhere else, there is no post-fetch hook. This
is not a show-stopper problem because the operation is local. You can
remember where the refs were before running a fetch, run the fetch, and
run necessary post-fetch operation. IOW, instead of "git fetch" (or
"git svn fetch") calling a custom script installed as a hook, a custom
script can call "git fetch" (or "git svn fetch") as part of what it
does.
However, fetch and push are logically the same operation --- update a
set of refs on one end to match the other end, while transferring the
necessary objects to keep the updated refs valid. We even suggest
(with satellite-mothership configuration) to push into remote when
network reachability constraints keeps you from fetching in the other
direction or vice versa. If you used fetch to update refs at the
receiving end only because you somehow cannot push in the other
direction, it is natural you would want to do the same processing after
the fetch that post-receive hook would have done if you could push in
the direction you originally wanted to.
Which suggests that we may be better off having a unified post-sync
hook, that would be called with the same arguments as existing
post-receive hook is called with, whenever fetch initiated at the local
end or a push initiated from elsewhere updates refs in the local
repository (such a hook is justified because it needs to _also_ work
at the remote side).
To keep the migration hassle to the minimum, we can reuse post-receive
hook itself for that purpose without actually introducing a new
post-sync hook. So how about calling post-receive from "git fetch" and
"git svn fetch"? This is a change in semantics, and it may break
people's existing setups (i.e. they may be relying on post-receive not
to trigger when they fetch), so we need to proceed carefully, but I
think it is in the right direction.
I actually am more than sympathetic to this cause. I think the unified post-sync mechanism is a sensible thing to do, at least in the longer term.
We might also need to teach push over http (which is not even a second class citizen) to trigger post-receive if it does not already do so.