mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-11 17:46:29 -05:00
Add support for fetching unadvertised SHA-1 (allow-tip-sha1-in-want capability) #5576
Open
opened 2025-11-02 06:29:22 -06:00 by GiteaMirror
·
11 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v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-rc2
v1.3.3
v1.4.0-rc1
v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
No Label
type/enhancement
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#5576
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @JustAnotherArchivist on GitHub (Jun 18, 2020).
I'd like to see the
allow-tip-sha1-in-wantcapability added to Gitea's Git server so that objects that aren't advertised inupload-packcan be fetched by a client. The primary use case that I'm aware of is fetching commits that were on branches that have been force-pushed over. In the context of pull requests, these previous commits can be important to understand the review process, for example. GitHub and GitLab.com (haven't tested GitLab CE) support this.For those who may not be that familiar with how a
git cloneworks, here's a quick summary: the client connects to the server and executesgit upload-pack. This returns the server's capabilities and a list of refs. The client then determines which of these refs they want and sends a series ofwant <SHA-1>lines to the server of the objects (and their history) it wants. The server then returns a packfile with those objects, and the client creates the desired local directory structure.However, even if the client fetches everything advertised by the server (e.g. with
--mirror), this only returns reachable commits. An example of unreachable commits are branches that were force-pushed over. Most notably, that is common in pull requests when major refactors of the PR code are necessary to keep the history clean after the merge. As long as garbage collection hasn't been run on the server, those commits still exist, and they can be fetched if the server supports theallow-tip-sha1-in-want:git fetch remote sha1will attempt to fetch the commit with hashsha1from the remoteremote.Example using GitHub and the recent PR #11032:
git clone --mirror https://github.com/go-gitea/gitea.gitcd gitea.gitgit show e4c89ba252341b8222dd72389b7407c3a0e05c99→fatal: bad object e4c89ba252341b8222dd72389b7407c3a0e05c99git fetch origin e4c89ba252341b8222dd72389b7407c3a0e05c99git show e4c89ba252341b8222dd72389b7407c3a0e05c99→commit e4c89ba252341b8222dd72389b7407c3a0e05c99etc.As of version 1.11.6 and the version deployed on gitea.com (see below), Gitea does not support step 4 (
error: Server does not allow request for unadvertised object <SHA-1>), which amounts to awant e4c89ba252341b8222dd72389b7407c3a0e05c99request from the client where that commit is not reachable from any ref.Example using https://gitea.com/gitea/homebrew-gitea/pulls/94:
git clone --mirror https://gitea.com/gitea/homebrew-gitea.gitcd homebrew-gitea.gitgit show 238dfca61957cd2b8b7c690a1ccea6481104c5b3→ bad object (as expected)git fetch origin 238dfca61957cd2b8b7c690a1ccea6481104c5b3→error: Server does not allow request for unadvertised object 238dfca61957cd2b8b7c690a1ccea6481104c5b3Since Gitea essentially just delegates the HTTP requests handling to Git (after auth checks etc.) in
routers/repo/http.go, I believe the only change that would be needed to support this would be enablinguploadpack.allowTipSHA1InWantin the repositories.On a related note, supporting
allow-reachable-sha1-in-wantakauploadpack.allowReachableSHA1InWantmay also be useful.@stale[bot] commented on GitHub (Aug 24, 2020):
This issue has been automatically marked as stale because it has not had recent activity. I am here to help clear issues left open even if solved or waiting for more insight. This issue will be closed if no further activity occurs during the next 2 weeks. If the issue is still valid just add a comment to keep it alive. Thank you for your contributions.
@lunny commented on GitHub (Aug 24, 2020):
This needs git v2.5.0
@zeripath commented on GitHub (Aug 29, 2020):
This is simply an option in .gitconfig or git config files in the repositories. Git capabilities are passed through by Gitea unaltered.
If you set uploadpack.allowTipSHA1InWant, uploadpack.hideRefs, uploadarchive.allowUnreachable etc. appropriately in git you can do this.
@lyz-code commented on GitHub (Dec 4, 2023):
I'm seeing this error too in some gitea actions pipelines when the CI tries to run
actions/checkout@v3on a merge commit on the main branch after a pull request merge.It's interesting because some pipelines work and others don't, it looks there is a race condition.
Any idea on how to solve this?
@wxiaoguang commented on GitHub (Dec 4, 2023):
You can set your own git config options by : Support changing git config through app.ini #24860
https://docs.gitea.com/administration/config-cheat-sheet#git---config-options-gitconfig
ec1feedbf5/custom/conf/app.example.ini (L712C6-L712C6)@wxiaoguang commented on GitHub (Dec 21, 2023):
If I understand correctly, the
checkoutaction shouldn't depend on this "unadvertised SHA-1" feature.What's the difference of these PRs? Maybe branch of the merged PR has been deleted so the CI are not able to checkout.
For this issue, I think it can be closed.
@JustAnotherArchivist commented on GitHub (Dec 21, 2023):
I'm not sure whether the CI situation is related. But the original issue, i.e. enabling
allowTipSHA1InWant(and possibly the other two options mentioned above) by default to allow fetching unadvertised commits, just like GitHub and GitLab do, is not resolved. I understand that it can be done by changing the configuration, but it should be on by default. Please reopen.@lyz-code commented on GitHub (Jan 8, 2024):
Sorry for the delay @wxiaoguang . The workflow that sometimes seems to show this issue is:
mainmainI'm guessing that the jobs that don't fail are the ones that the checkout phase of the
mainjob is run before the automatic deletion of the pull request branch@lyz-code commented on GitHub (Feb 6, 2024):
Fetching the whole history with
fetch-depth: 0worked for us:@my1e5 commented on GitHub (Mar 6, 2024):
Also getting this issue with
actions/checkout@v3using thedemo.yamlworkflow.Actions run fine at first, but if I go back to old commits and try re-run the action it fails with this
Server does not allow request for unadvertised objecterror. I'm on the same branch and haven't done any PRs, I'm simply a number of commits ahead - but I guess these commits are now somehow 'unreachable'? I've tested usingwith: fetch-depth: 0and this does solve the problem. But I feel by default everything should be configured nicely to work - especially whenuses: actions/checkout@v3is part of the demo workflow and there is no note to say it can break if you don't use it withfetch-depth: 0. It can be puzzling to the end user if the demo workflow which used to run fine suddenly stops working. So I would support @JustAnotherArchivist proposal to make the necessary configs enabled by default.@GiteaBot commented on GitHub (Apr 6, 2024):
We close issues that need feedback from the author if there were no new comments for a month. 🍵