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

Re: [PATCH] add receive.denyNonFastforwards config variable

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Sep 21, 2006, 00:10 UTC
Message-ID
<Pine.LNX.4.63.0609210208350.19042@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<7vzmcudt3t.fsf@assigned-by-dhcp.cox.net>
Hi,
On Wed, 20 Sep 2006, Junio C Hamano wrote:
Show 17 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > If receive.denyNonFastforwards is set to true, git-receive-pack will deny
> > non fast-forwards, i.e. forced updates. Most notably, a push to a repository
> > which has that flag set will fail.
> >
> > As a first user, 'git-init-db --shared' sets this flag, since in a shared
> > setup, you are most unlikely to want forced pushes to succeed.
> >
> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
> 
> Looks good.  Care to do a handful more tasks before we forget?
> 
>  Documentation/git-init-db.txt
>  Documentation/config.txt
>  Documentation/git-receive-pack.txt
>  t/t5400-send-pack.sh or a new test t/t5401-push-into-shared-repo.sh
I expected Jakub to ask for it ;-)

-- snip -- [PATCH] Document receive.denyNonFastforwards

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
 Documentation/config.txt           |    7 +++++++
 Documentation/git-init-db.txt      |    4 ++++
 Documentation/git-receive-pack.txt |    2 ++
 t/t5400-send-pack.sh               |   10 ++++++++++
 4 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 844cae4..6802d30 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -267,3 +267,10 @@ whatchanged.difftree::
 imap::
 	The configuration variables in the 'imap' section are described
 	in gitlink:git-imap-send[1].
+
+receive.denyNonFastforwads::
+	If set to true, git-receive-pack will deny a ref update which is
+	not a fast forward. Use this to prevent such an update via a push,
+	even if that push is forced. This configuration variable is
+	set when initializing a shared repository.
+	
diff --git a/Documentation/git-init-db.txt b/Documentation/git-init-db.txt
index 63cd5da..ca7d09d 100644
--- a/Documentation/git-init-db.txt
+++ b/Documentation/git-init-db.txt
@@ -48,6 +48,10 @@ is given:
  - 'all' (or 'world' or 'everybody'): Same as 'group', but make the repository
    readable by all users.
 
+By default, the configuration flag receive.denyNonFastforward is enabled
+in shared repositories, so that you cannot force a non fast-forwarding push
+into it.
+
 --
 
 
diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt
index f9457d4..0dfadc2 100644
--- a/Documentation/git-receive-pack.txt
+++ b/Documentation/git-receive-pack.txt
@@ -73,6 +73,8 @@ packed and is served via a dumb transpor
 There are other real-world examples of using update and
 post-update hooks found in the Documentation/howto directory.
 
+git-receive-pack honours the receive.denyNonFastforwards flag, which
+tells it if updates to a ref should be denied if they are not fast-forwards.
 
 OPTIONS
 -------
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index f3694ac..6be3c80 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -64,4 +64,14 @@ test_expect_success \
 	cmp victim/.git/refs/heads/master .git/refs/heads/master
 '
 
+test_expect_success \
+        'pushing with --force should be denied with denyNonFastforwards' '
+	cd victim &&
+	git-repo-config receive.denyNonFastforwards true &&
+	cd .. &&
+	git-update-ref refs/heads/master master^ &&
+	git-send-pack --force ./victim/.git/ master &&
+	! diff -u .git/refs/heads/master victim/.git/refs/heads/master
+'
+
 test_done
-- 
1.4.2.1.g6ad2-dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 6 of 18 in “add receive.denyNonFastforwards config variable”
  1. add receive.denyNonFastforwards config variableJohannes Schindelin, Sep 20, 2006
  2. Junio C HamanoSep 20, 2006
  3. Shawn PearceSep 20, 2006
  4. add receive.denyNonFastforwards config variableJohannes Schindelin, Sep 20, 2006
  5. Junio C HamanoSep 20, 2006
  6. Johannes SchindelinSep 21, 2006
  7. Junio C HamanoSep 21, 2006
  8. Johannes SchindelinSep 21, 2006
  9. Junio C HamanoSep 20, 2006
  10. Johannes SchindelinSep 21, 2006
  11. Junio C HamanoSep 21, 2006
  12. Jeff KingSep 21, 2006
  13. Junio C HamanoSep 21, 2006
  14. Johannes SchindelinSep 21, 2006
  15. Junio C HamanoSep 21, 2006
  16. Jeff KingSep 20, 2006
  17. Johannes SchindelinSep 21, 2006
  18. Junio C HamanoSep 21, 2006

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.