-
Notifications
You must be signed in to change notification settings - Fork 534
Fix fetch tags #407
Fix fetch tags #407
Conversation
remote.go
Outdated
@@ -329,6 +329,21 @@ func getWants( | |||
} | |||
} | |||
|
|||
tags := []plumbing.Hash{} |
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.
Prefer var tags []plumbing.Hash
initialization.
remote.go
Outdated
return nil, err | ||
} | ||
|
||
localIter.ForEach(func(ref *plumbing.Reference) error { |
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.
Check return error.
@zacharya19 Thanks for the contribution! I wonder how this works. If I understood correctly, this implies that the repository contains a tag returned by That should not happen at all. Could you give more details about a repository exhibiting this error? Did you clone it with go-git from the beginning? Or did you clone with git and then pulled with go-git? I suspect that if this fix works, it's only because there is a related bug that has lead the repository into an inconsistent state. |
Codecov Report
@@ Coverage Diff @@
## master #407 +/- ##
==========================================
- Coverage 78.03% 77.51% -0.52%
==========================================
Files 127 127
Lines 9186 9310 +124
==========================================
+ Hits 7168 7217 +49
- Misses 1237 1313 +76
+ Partials 781 780 -1
Continue to review full report at Codecov.
|
@smola I use PlainOpen to open a repo I cloned with git cli. |
BTW - the tag could not by exists locally if the hash does not exists locally, am I wrong? |
@zacharya19 This code implies that tags have hashes of objects that are not in the object storage. A tag is either a tag object (in the object storage) or a reference to a non-tag object (in the object storage too). So if there are cases where
|
Not sure I got it, since the problem here is the opposite, on the remote we see tags that point to an hash that exists locally, but the tag it self does not exist. |
@zacharya19 Ok. This can happen with lightweight tags. Although, this still wouldn't fix the case where a tag |
@smola I made some changes, let me know what you think. |
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.
Thank you @zacharya19, looks good!
We should add a test for this though. |
I'm working on a proper test before moving on. |
@smola I added basic test, let me know what you think. |
@zacharya19 thanks for your efforts and your time, but I created another PR #485 with a canonical solution. |
Quick fix for #371.
Not sure it's the best way, but this bug is very disturbing to me, so I fixed it quickly.
In tags we do not need to check hash, we need to check if it's name exists in the local storer, so I saved all local tags in slice and then if the reference is a tag, I say it's exists if it's in the slice.
Better idea?