git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Alexey Shumkin <alex.crezoff@gmail.com>
Date
Apr 10, 2012, 14:49 UTC
Message-ID
<20120410184923.7198bf4a@ashu.dyn1.rarus.ru>
In-Reply-To
<20120410175917.0942d8f2@ashu.dyn1.rarus.ru>

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
> 
Previous: Alexey Shumkin
Message 2 of 2 in “pre-receive/update hook: how to know forced push?”
  1. Alexey ShumkinApr 10, 2012
  2. Alexey ShumkinApr 10, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.