threads / discuss / 14812

git svn and the post-receive hook

Subject: git svn and the post-receive hook

## tl;dr

7 messages between Aug 2, 2008 and Aug 2, 2008.

replies: 6people: 3as markdown or json

Pascal Obry· Aug 2, 2008, 16:05 UTC · lore

At the moment it seems to me that the post-receive hook is not called when tracking a remove Subversion repository.

I think it would be nice to call the post-receive hook at the end of:
    $ git svn rebase
Why I need this?

I'd like to check for example that if a file has been added to the remote Subversion repository then it is properly added into a MANIFEST file. I'd also like to check some style rules. This would help to detect some problems when one has no way to add hooks on the Subversion repository.

I have zero experience with Perl so I do not feel like hacking this myself.
What do you think?
Is this already possible (I may have missed something)?

Thanks, Pascal.

-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Miklos Vajna· Aug 2, 2008, 18:03 UTC · re: Pascal Obry · lore

Re: git svn and the post-receive hook

On Sat, Aug 02, 2008 at 06:05:16PM +0200, Pascal Obry <pascal@obry.net> wrote:
> At the moment it seems to me that the post-receive hook is not called when 
> tracking a remove Subversion repository.
Sure. From the "post-receive" hook documentation:

"This hook is invoked by 'git-receive-pack' on the remote repository, which happens when a 'git-push' is done on a local repository."

And git svn will never invoke git receive-pack.
> I think it would be nice to call the post-receive hook at the end of:
> 
>    $ git svn rebase
What about a post-rebase hook, like there is a post-merge one?
> I have zero experience with Perl so I do not feel like hacking this myself.
git rebase is shell. ;-)
Junio C Hamano· Aug 2, 2008, 18:22 UTC · re: Pascal Obry · lore

Re: git svn and the post-receive hook

Pascal Obry <pascal@obry.net> writes:
Show 10 quoted lines
> At the moment it seems to me that the post-receive hook is not called
> when tracking a remove Subversion repository.
>
> I think it would be nice to call the post-receive hook at the end of:
>
>    $ git svn rebase
>
> Why I need this?
>
> I'd like to check ...
Wait a minute.

Isn't "git svn rebase" an operation that you do on your local repository, slurping the update from the other end and then replaying your change on top of it? If so, I think it falls into the same category as "post-fetch" hook which would run after you run fetch, if such a thing existed. See:

    http://thread.gmane.org/gmane.comp.version-control.git/79306/focus=79321
for the reason why we usually do not add such a hook on the local end.
Junio C Hamano· Aug 2, 2008, 18:43 UTC · re: Pascal Obry · lore

Re: git svn and the post-receive hook

Pascal Obry <pascal@obry.net> writes:
Show 5 quoted lines
> I'd like to check for example that if a file has been added to the
> remote Subversion repository then it is properly added into a MANIFEST
> file. I'd also like to check some style rules. This would help to
> detect some problems when one has no way to add hooks on the
> Subversion repository.

Are you saying that there may be breakages that is made at the Subversion side, and you would want to catch it?

What would you do _after_ finding out that somebody screwed up and you have a borked history on the Subversion side already?

I do not think this belongs to "git svn rebase" (let alone "git rebase", no way --- you won't rewrite nor reject the upstream even if you find problems with it).

I understand that you would at least want to notice the damange to the history that happened at the remote end, and I agree it would make sense to do something like:

	$ git command-that-updates-the-remote-tracking-branch git-svn
        $ check-history git-svn@{1}..git-svn
The "command-that-updates" could be "svn fetch" or just a simple "fetch".

But the "check-history" script will be very specific to your project, and I do not think it makes sense to make it a hook to the "command-that-updates".

Pascal Obry· Aug 2, 2008, 19:20 UTC · re: Junio C Hamano · lore

Re: git svn and the post-receive hook

Junio,
> Are you saying that there may be breakages that is made at the Subversion
> side, and you would want to catch it?
Exactly.
> What would you do _after_ finding out that somebody screwed up and you
> have a borked history on the Subversion side already?
Notify the developer(s) about the problem(s).
Show 15 quoted lines
> I do not think this belongs to "git svn rebase" (let alone "git rebase",
> no way --- you won't rewrite nor reject the upstream even if you find
> problems with it).
> 
> I understand that you would at least want to notice the damange to the
> history that happened at the remote end, and I agree it would make sense
> to do something like:
> 
> 	$ git command-that-updates-the-remote-tracking-branch git-svn
>         $ check-history git-svn@{1}..git-svn
> 
> The "command-that-updates" could be "svn fetch" or just a simple "fetch".
> 
> But the "check-history" script will be very specific to your project, and
> I do not think it makes sense to make it a hook to the "command-that-updates".

Hum... Any hook is very specific to a project. That's why it is a hook and not a built-in command.

BTW, I do not see why this would be a problem with git-svn whereas the post-receive hook is fine for Git. In many projects rewriting history is not permitted but post-receive is quite handy to do some checks.

post-received receive 3 parameters:
   - sha before
   - sha after
   - refname
It is perfectly usable after a git-svn rebase.
Pascal.
-- 
--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
Junio C Hamano· Aug 2, 2008, 20:16 UTC · re: Pascal Obry · lore

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.

Miklos Vajna· Aug 2, 2008, 20:45 UTC · re: Junio C Hamano · lore

Re: git svn and the post-receive hook

On Sat, Aug 02, 2008 at 01:16:05PM -0700, Junio C Hamano <gitster@pobox.com> wrote:
> 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.

That would be nice, but as far as I understand that is not possible without ugly hacks like subversion's mod_svn or a CGI script. Or did you refer to the later?

← back to recent threads