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

Corrupt repo with force push when using a reference repo

From
GSGrant Singleton <grant_singleton@trimble.com>
Date
Aug 15, 2023, 04:05 UTC
Message-ID
<MN2PR03MB5072F08C68E7F32C9F5AC866A614A@MN2PR03MB5072.namprd03.prod.outlook.com>

Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
With 3 clones of a repo, one on branch-a one a mirror,  another using the mirror as a reference repo on branch-b, do the following

# in the repo on branch-a, make a change, commit and push cd bad-object-test echo $(( RANDOM % 1000 + 1 )) > file.txt git ci -am "change a file" git push

# do a git fetch in the reference repo cd ../bad-object-test.git/ git fetch

# do a git pull in the repo on branch-b cd ../bad-object-test-with-reference-repo/ git pull

# All good so far

# in the repo on branch-a, discard HEAD and force push cd ../bad-object-test git reset --hard HEAD~1 git push --force

# do a git fetch in the reference repo and then prune loose objects cd ../bad-object-test.git/ git fetch git prune -v --expire=now

# do a git pull in the repo on branch-b cd ../bad-object-test-with-reference-repo git pull

What did you expect to happen? (Expected behavior)
the repo on branch-b does a force update of romote tracking branch branch-a

What happened instead? (Actual behavior) xxx> git pull fatal: bad orefs/remotes/origin/branch-a error: https://github.com/xxxxx/yyyyyyy.git did not send all necessary objects

What's different between what you expected and what actually happened?
I expected the force push to succeed, but insted I get a corrupt repo
Anything else you want to add:

git rev-parse refs/remotes/origin/branch-a will return the hash of the commit that was discarded by the git reset command

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.41.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64 compiler info: gnuc: 11.3 libc info: glibc: 2.35 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
Next: brian m. carlson
Message 1 of 3 in “Corrupt repo with force push when using a reference repo”
  1. Grant SingletonAug 15, 2023
  2. brian m. carlsonAug 16, 2023
  3. U-AP\GSingletonAug 22, 2023

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.