threads / discuss / 30194

pre-receive/update hook: how to know forced push?

Subject: pre-receive/update hook: how to know forced push?

## tl;dr

2 messages between Apr 10, 2012 and Apr 10, 2012.

replies: 1people: 1as markdown or json

Alexey Shumkin· Apr 10, 2012, 13:59 UTC · lore
Hi, guys!

How to know in pre-receive hook that commit has been pushed with --force option?

I've written some pre-receive hook that denies pushed commits which have author's date earlier then current branch HEAD. It's done to prevent not triggering automated builds which are based on authors' timestamps.

But some time later I had to rollback branch to previous state. It is not convenient way to "git update-ref ..." on the server, I'd like to git push --force, but there is a question in the first sentence:

How to know in pre-receive hook that commit has been pushed with --force option?

Thanx in advance
Alexey Shumkin· Apr 10, 2012, 14:49 UTC · re: Alexey Shumkin · lore

Re: pre-receive/update hook: how to know forced push?

After some investigation of sources it seems to me decision to push changes to server or not is made by git client, so server can only reject pushed updates.

Some examples of necessary detections can be found in 'contrib/hooks/post-receive-email' hook.

Sorry for the noise
Show 20 quoted lines
> Hi, guys!
> 
> How to know in pre-receive hook that commit has been pushed with
> --force option?
> 
> I've written some pre-receive hook that denies pushed commits which
> have author's date earlier then current branch HEAD. It's done to
> prevent not triggering automated builds which are based on authors'
> timestamps.
> 
> But some time later I had to rollback branch to previous state.
> It is not convenient way to "git update-ref ..." on the server, I'd
> like to git push --force, but there is a question in the first
> sentence:
> 
> How to know in pre-receive hook that commit has been pushed with
> --force option?
> 
> Thanx in advance
> 

← back to recent threads