Skip to content

Commit cf6cf0d

Browse files
committed
worktree: add sentinel error for non-fast-forward pull
Signed-off-by: Alexey Smirnov <[email protected]>
1 parent 00629a1 commit cf6cf0d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

worktree.go

+6-5
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

+1-1
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)