git svn and the post-receive hook

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

git svn and the post-receive hook

Pascal Obry

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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Miklos Vajna
On Sat, Aug 02, 2008 at 06:05:16PM +0200, Pascal Obry <[hidden email]> 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. ;-)

attachment0 (204 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Junio C Hamano
In reply to this post by Pascal Obry
Pascal Obry <[hidden email]> writes:

> 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.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Junio C Hamano
In reply to this post by Pascal Obry
Pascal Obry <[hidden email]> writes:

> 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".
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Pascal Obry

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).

> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Junio C Hamano
Pascal Obry <[hidden email]> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [hidden email]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Reply | Threaded
Open this post in threaded view
|

Re: git svn and the post-receive hook

Miklos Vajna
On Sat, Aug 02, 2008 at 01:16:05PM -0700, Junio C Hamano <[hidden email]> 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?

attachment0 (204 bytes) Download Attachment