Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git fetch-by-commit still includes --tags, which can fail #5567

Open
tianon opened this issue Dec 4, 2024 · 2 comments
Open

Git fetch-by-commit still includes --tags, which can fail #5567

tianon opened this issue Dec 4, 2024 · 2 comments

Comments

@tianon
Copy link
Member

tianon commented Dec 4, 2024

When building via a Git URL, #5441 added support for directly fetching via the commit (which is notably supported by GitHub). Prior to that, #5072 had added --tags to the git fetch invocations as a partial fix for the same underlying issue (not fetching commits which were part of a tag but not a branch).

However, these two together can now cause issues fetching (in the case of existing cache + updated related tags):

#1 [internal] load git source https://github.com/nginxinc/docker-nginx.git#d21b4f2d90a1abb712a610678872e804267f4815:mainline/alpine-slim
fatal: Not a valid object name d21b4f2d90a1abb712a610678872e804267f4815^{commit}
From https://github.com/nginxinc/docker-nginx
 * branch            d21b4f2d90a1abb712a610678872e804267f4815 -> FETCH_HEAD
 ! [rejected]        1.25.5     -> 1.25.5  (would clobber existing tag)

The workaround is simple (clearing the cache and trying again, waiting for the cache to expire naturally, etc), but it would probably be better to update the fetching logic to be something like:

  • if ref is a commit, try direct fetch-only-by-commit
  • if ref is not a commit, fetch specified ref directly
  • worst case, fetch all branches+tags and hope the specified ref comes in

(cc @jedevc ❤️)

@tonistiigi
Copy link
Member

Does this also require that the commit that the tag points to needs to change in upstream? Otherwise, I don't understand what this error means.

@tianon
Copy link
Member Author

tianon commented Dec 6, 2024

To reproduce the error I found this bug with, yes, I think the upstream tag needs to change. However, since we're doing a build-by-commit, we shouldn't be fetching the tag in the first place (or caring about/updating it during this fetch).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants