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

Commit dcc9f37

Browse files
authored
Merge pull request #1064 from asv/sentinel_error_for_no_ff_update
worktree: add sentinel error for non-fast-forward pull
2 parents 00629a1 + cf6cf0d commit dcc9f37

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

worktree.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ import (
2525
)
2626

2727
var (
28-
ErrWorktreeNotClean = errors.New("worktree is not clean")
29-
ErrSubmoduleNotFound = errors.New("submodule not found")
30-
ErrUnstagedChanges = errors.New("worktree contains unstaged changes")
31-
ErrGitModulesSymlink = errors.New(gitmodulesFile + " is a symlink")
28+
ErrWorktreeNotClean = errors.New("worktree is not clean")
29+
ErrSubmoduleNotFound = errors.New("submodule not found")
30+
ErrUnstagedChanges = errors.New("worktree contains unstaged changes")
31+
ErrGitModulesSymlink = errors.New(gitmodulesFile + " is a symlink")
32+
ErrNonFastForwardUpdate = errors.New("non-fast-forward update")
3233
)
3334

3435
// Worktree represents a git worktree.
@@ -101,7 +102,7 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error {
101102
}
102103

103104
if !ff {
104-
return fmt.Errorf("non-fast-forward update")
105+
return ErrNonFastForwardUpdate
105106
}
106107
}
107108

worktree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func (s *WorktreeSuite) TestPullNonFastForward(c *C) {
119119
c.Assert(err, IsNil)
120120

121121
err = w.Pull(&PullOptions{})
122-
c.Assert(err, ErrorMatches, "non-fast-forward update")
122+
c.Assert(err, Equals, ErrNonFastForwardUpdate)
123123
}
124124

125125
func (s *WorktreeSuite) TestPullUpdateReferencesIfNeeded(c *C) {

0 commit comments

Comments
 (0)