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

Re: Git 2 force commits but Git 1 doesn't

From
MWMichael Ward <mward@smartsoftwareinc.com>
Date
Jun 22, 2020, 22:17 UTC
Message-ID
<2e43580c-9952-9ccf-6b35-27a4333fb83e@smartsoftwareinc.com>
In-Reply-To
<20200622210953.GQ6531@camp.crustytoothpaste.net>
This is assuming that the repository is completely empty to start. Setup:

git clone [repository] repo1 git clone [repository] repo2 cd repo1 echo "test1" > testfile git add testfile git commit -m 'initializing test from 1' git push cd ../repo2 git pull cd ../repo1

Now for the issue:

echo "test1 update" >> testfile git add testfile git commit -m 'update test from 1' git push cd ../repo2 echo "test2" >> testfile git commit -m 'update test from 2' git push

At this point using the git 2.26 client if I pull in repo1, the commit with comment "update test from 1" is gone and the head is now the commit from 2 with "update test from 2" as the comment along with a borked tree. Using the 1.18 client, the push from 2 will prompt to pull first.

Michael
On 6/22/20 4:09 PM, brian m. carlson wrote:
Show 26 quoted lines
> On 2020-06-22 at 20:52:50, Michael Ward wrote:
>> Using the steps from my original email for how I had the repository set up
>> (any user authentication scheme works), clone 2 copies from that repository
>> (call them A and B). Make, commit, and push a change in A. Then make,
>> commit, and push a change in B (without first pulling). With the 1.8 client,
>> B will prompt that you're out of date and need to update. With the 2.26
>> client, B's commit will be pushed and be forced.
> I think we're going to need a more specific set of reproduction steps,
> because adding the following to t5540 succeeds (starting on branch
> "dev"):
>
> test_expect_success 'non-force push fails if not up to date' '
> 	git push origin dev &&
> 	git reset --hard HEAD^ &&
> 	: >path3 &&
> 	git add path3 &&
> 	test_tick &&
> 	git commit -m dev &&
> 	test_must_fail git push origin dev &&
> 	git push origin +dev
> '
>
> That means that this is working in at least some cases.  If you're still
> seeing this, can you provide a set of commands (e.g., a shell script) to
> initialize and create a new repository that triggers this, provided that
> "origin" refers to a suitable remote?
Previous: brian m. carlsonNext: brian m. carlson
Message 8 of 19 in “Git 2 force commits but Git 1 doesn't”
  1. Michael WardJun 22, 2020
  2. brian m. carlsonJun 22, 2020
  3. Michael WardJun 22, 2020
  4. Michael WardJun 22, 2020
  5. brian m. carlsonJun 22, 2020
  6. Michael WardJun 22, 2020
  7. brian m. carlsonJun 22, 2020
  8. Michael WardJun 22, 2020
  9. brian m. carlsonJun 23, 2020
  10. René ScharfeJun 23, 2020
  11. brian m. carlsonJun 23, 2020
  12. René ScharfeJun 23, 2020
  13. brian m. carlsonJun 23, 2020
  14. René ScharfeJun 24, 2020
  15. http-push: ensure unforced pushes fail when data would be lostbrian m. carlson, Jun 23, 2020
  16. Eric SunshineJun 23, 2020
  17. brian m. carlsonJun 23, 2020
  18. http-push: ensure unforced pushes fail when data would be lostbrian m. carlson, Jun 23, 2020
  19. Junio C HamanoJun 23, 2020

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.