Skip to content

Commit b74ae19

Browse files
committed
add test for pulling after shallow clone
1 parent 45307e0 commit b74ae19

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

remote.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,9 @@ func isFastForward(s storer.EncodedObjectStorer, old, new plumbing.Hash, earlies
11001100

11011101
found := false
11021102
// stop iterating at the earlist shallow commit, ignoring its parents
1103+
// note: when pull depth is smaller than the number of new changes on the remote, this fails due to missing parents.
1104+
// as far as i can tell, without the commits in-between the shallow pull and the earliest shallow, there's no
1105+
// real way of telling whether it will be a fast-forward merge.
11031106
iter := object.NewCommitPreorderIter(c, nil, parentsToIgnore)
11041107
err = iter.ForEach(func(c *object.Commit) error {
11051108
if c.Hash != old {

worktree_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,42 @@ func (s *WorktreeSuite) TestPullDepth(c *C) {
313313
c.Assert(err, Equals, nil)
314314
}
315315

316+
func (s *WorktreeSuite) TestPullAfterShallowClone(c *C) {
317+
tempDir, clean := s.TemporalDir()
318+
defer clean()
319+
remoteURL := filepath.Join(tempDir, "remote")
320+
repoDir := filepath.Join(tempDir, "repo")
321+
322+
remote, err := PlainInit(remoteURL, false)
323+
c.Assert(err, IsNil)
324+
c.Assert(remote, NotNil)
325+
326+
_ = CommitNewFile(c, remote, "File1")
327+
_ = CommitNewFile(c, remote, "File2")
328+
329+
repo, err := PlainClone(repoDir, false, &CloneOptions{
330+
URL: remoteURL,
331+
Depth: 1,
332+
Tags: NoTags,
333+
SingleBranch: true,
334+
ReferenceName: "master",
335+
})
336+
c.Assert(err, IsNil)
337+
338+
_ = CommitNewFile(c, remote, "File3")
339+
_ = CommitNewFile(c, remote, "File4")
340+
341+
w, err := repo.Worktree()
342+
c.Assert(err, IsNil)
343+
344+
err = w.Pull(&PullOptions{
345+
RemoteName: DefaultRemoteName,
346+
SingleBranch: true,
347+
ReferenceName: plumbing.NewBranchReferenceName("master"),
348+
})
349+
c.Assert(err, IsNil)
350+
}
351+
316352
func (s *WorktreeSuite) TestCheckout(c *C) {
317353
fs := memfs.New()
318354
w := &Worktree{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy