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

receive.denyCurrentBranch=updateInstead updates working tree even when receive.denyNonFastForwards rejects push

From
RMRajesh Madamanchi <rmadamanchi@gmail.com>
Date
Oct 16, 2018, 18:54 UTC
Message-ID
<CANahLXm7O6scvLdaL6bm14d5oGM5Zp+S-rpQDo554ssagRFNoQ@mail.gmail.com>

Hi, I am looking to report the below behavior when seems incorrect to me when receive.denyCurrentBranch is set to updateInstead and receive.denyNonFastForwards is set to true. Below are the steps to reproduce the scenario. Please excuse my ignorance if I'm missing something fundamental.

Step 1 - Setup remote repository (remote host): git config --global receive.denyCurrentBranch updateInstead git config --global receive.denyNonFastForwards true mkdir /tmp/hello cd /tmp/hello git init echo hello > hello.txt git add . && git commit -m "hello.txt"

Step 2 - Create 2 Clones (local host): git clone ssh://REMOTEIP/tmp/hello /tmp/hello1 git clone ssh://REMOTEIP/tmp/hello /tmp/hello2

Step 3 - Push a commit from Clone 1 cd /tmp/hello1 echo hello1 > hello1.txt git add . && git commit -m "hello1.txt" git push --> at this point server working tree contains hello1.txt which is expected

Step 4: Try to force push a commit from Clone 2 cd /tmp/hello2 echo hello2 > hello2.txt git add . && git commit -m "hello2.txt" git push --> Remote rejects with message that remote contains work i do not have locally git push --force --> Remote rejects again with error: denying non-fast-forward refs/heads/master (you should pull first) --> At this point, since the push is rejected, I expect the servers working tree to not contain any rejected changes. BUT the servers working tree got updated to delete hello1.txt and create hello2.txt. Push rejected but not really.

I also noticed the same behavior (incorrect) when the update hook rejects changes on the server (but not the pre-receive hook).

Thank you
Next: Junio C Hamano
Message 1 of 6 in “receive.denyCurrentBranch=updateInstead updates working tree even when receive.denyNonFastForwards rejects push”
  1. Rajesh MadamanchiOct 16, 2018
  2. Junio C HamanoOct 19, 2018
  3. Junio C HamanoOct 19, 2018
  4. receive: denyCurrentBranch=updateinstead should not blindly updateJunio C Hamano, Oct 19, 2018
  5. Eric SunshineOct 19, 2018
  6. Johannes SchindelinOct 22, 2018

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.