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

Re: [PATCH] add receive.denyNonFastforwards config variable

From
Junio C Hamano <junkio@cox.net>
Date
Sep 21, 2006, 06:26 UTC
Message-ID
<7vfyeld9c2.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<Pine.LNX.4.63.0609210208350.19042@wbgn013.biozentrum.uni-wuerzburg.de>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 19 quoted lines
> 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

The change shown by "git -SGIT_CONFIG -p t/Makefile" seems to interfere with this test. When I run it from shell by hand it works OK, but when I run it like this:

	cd t && make T=t5400*.sh

it barfs. s/git-send-pack/strace -f git-send-pack/ seems to indicate that the receiving end is trying to open .git/config (rightly, because you told it to do so three months ago ;-) while its $cwd is victim/.git and fails to read the setting you are trying to test. Not good.

I think the change to t/Makefile from 9c3796fc needs to be rethought. Most of the tests would be fine with .git/config (they never step outside t/trash/.git repository), but others need tweaking, including unsetting it (while unsetting HOME at the same time perhaps when you do not want to be affected). Also it may make sense to do the default setting of GIT_CONFIG in t/test-lib.sh, with a prominent warning why we explicitly set it to a known value.

In the meantime, I got things working with this patch on top of your test update.

---
diff --git a/t/t5400-send-pack.sh b/t/t5400-send-pack.sh
index 6be3c80..be47ee2 100755
--- a/t/t5400-send-pack.sh
+++ b/t/t5400-send-pack.sh
@@ -64,6 +64,10 @@ test_expect_success \
 	cmp victim/.git/refs/heads/master .git/refs/heads/master
 '
 
+unset GIT_CONFIG GIT_CONFIG_LOCAL
+HOME=`pwd`/no-such-directory
+export HOME ;# this way we force the victim/.git/config to be used.
+
 test_expect_success \
         'pushing with --force should be denied with denyNonFastforwards' '
 	cd victim &&
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 7 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.