Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit cbcbe03

Browse files
authored
remote: fix empty-git-upload-pack error in fetch, when the reference points to a non-commit object (#209)
1 parent c5f1056 commit cbcbe03

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

remote.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ func getWants(spec []config.RefSpec, localStorer Storer, remoteRefs storer.Refer
355355
}
356356

357357
hash := ref.Hash()
358-
exists, err := commitExists(localStorer, hash)
358+
359+
exists, err := objectExists(localStorer, hash)
359360
if err != nil {
360361
return err
361362
}
@@ -378,8 +379,8 @@ func getWants(spec []config.RefSpec, localStorer Storer, remoteRefs storer.Refer
378379
return result, nil
379380
}
380381

381-
func commitExists(s storer.EncodedObjectStorer, h plumbing.Hash) (bool, error) {
382-
_, err := s.EncodedObject(plumbing.CommitObject, h)
382+
func objectExists(s storer.EncodedObjectStorer, h plumbing.Hash) (bool, error) {
383+
_, err := s.EncodedObject(plumbing.AnyObject, h)
383384
if err == plumbing.ErrObjectNotFound {
384385
return false, nil
385386
}

remote_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,17 @@ func (s *RemoteSuite) TestFetchWithPackfileWriter(c *C) {
171171

172172
func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDate(c *C) {
173173
url := s.GetBasicLocalRepositoryURL()
174+
s.doTestFetchNoErrAlreadyUpToDate(c, url)
175+
}
176+
177+
func (s *RemoteSuite) TestFetchNoErrAlreadyUpToDateWithNonCommitObjects(c *C) {
178+
fixture := fixtures.ByTag("tags").One()
179+
url := s.GetLocalRepositoryURL(fixture)
180+
s.doTestFetchNoErrAlreadyUpToDate(c, url)
181+
}
182+
183+
func (s *RemoteSuite) doTestFetchNoErrAlreadyUpToDate(c *C, url string) {
184+
174185
sto := memory.NewStorage()
175186
r := newRemote(sto, nil, &config.RemoteConfig{Name: "foo", URL: url})
176187

0 commit comments

Comments
 (0)