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
fix: empty git-upload-pack given on remote.fetch() #447
Conversation
More info: This change prevents an attempt to upload pack when UploadPackRequest is empty. Partial Resolution: go-git#328 Signed-off-by: Paul Greenberg <greenpau@outlook.com>
can you cover it with some test? |
@mcuadros , will do! 👍 will also need to do some adjustments to the code. |
@mcuadros , moved the check to the Here, I add the same to the
Created Receiving the following error in the unrelated
I am not 💯 sure about the |
This patch doesn't help in my situation, which perhaps isn't surprising since I'm not making a shallow fetch. What's puzzling to me is that the wanted SHA-1 in wants really exists in the haves list so it's clear why isEmpty returns true. But shouldn't a commit in haves be available in the git, i.e. a checkout or I apologize if you think I'm derailing your PR, maybe my problem is something entirely different (mysterious problems are often a case of PEBKAC), but it might also hint at a different root cause whereas the current state of this PR only addresses a particular corner case. Either way, I'd be happy to help debug the problem. |
@magnusbaeck , this is valuable discussion! 👍 Please challenge, propose something new, etc. |
The reason my wanted SHA-1 ended up in haves was that HEAD contained that SHA-1. My code looks like this: err = worktree.Checkout(&git.CheckoutOptions{
Hash: plumbing.NewHash(commitID),
Force: true,
})
if errors.Is(err, plumbing.ErrObjectNotFound) {
refSpec := fmt.Sprintf("+%s:tmp", ref)
err = gr.git.FetchContext(ctx, &git.FetchOptions{
RefSpecs: []gitconfig.RefSpec{gitconfig.RefSpec(refSpec)},
Tags: git.NoTags,
})
... It seems the failing checkout operation still ends up storing the wanted SHA-1 in HEAD, so when the subsequent fetch operation computes the haves set it picks up the SHA-1 from HEAD, resulting in an empty (wants − haves) set and hence ErrEmptyUploadPackRequest. I'll double check to make sure the SHA-1 didn't end up in HEAD by other means, but if my analysis is correct I'll file an issue for the checkout behavior unless there already is one. |
For posterity my unrelated problem was filed as #457. |
Commit cherry-picked from greenpau@1955d37 Upstream PR: go-git#447
}) | ||
|
||
s.testFetch(c, r, &FetchOptions{ | ||
Depth: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you test it with non-zero value?
@l0nax , I cannot merge that. Not a maintainer of this package. |
1 similar comment
@l0nax , I cannot merge that. Not a maintainer of this package. |
@greenpau do you mind rebasing your PR and also adding a test case to validate non-zero values for Depth? |
@pjbgf , I rebased. Unfortunately, it has been a while since I looked into this code. Could you add a test yourself? |
This can be closed as it was fixed in #792 |
More info: This change prevents an attempt to upload pack
when UploadPackRequest is empty.
Partial Resolution: #328
Signed-off-by: Paul Greenberg greenpau@outlook.com