Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b74ae19

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

File tree

Expand file treeCollapse file tree

2 files changed

+39
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+39
-0
lines changed

‎remote.go

Copy file name to clipboardExpand all lines: remote.go
+3Lines 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

Copy file name to clipboardExpand all lines: worktree_test.go
+36Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.