aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--worktree.go8
-rw-r--r--worktree_test.go20
2 files changed, 27 insertions, 1 deletions
diff --git a/worktree.go b/worktree.go
index 7f394d4..d272373 100644
--- a/worktree.go
+++ b/worktree.go
@@ -93,10 +93,16 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error {
head, err := w.r.Head()
if err == nil {
- if !updated && head.Hash() == ref.Hash() {
+ headAheadOfRef,err := isFastForward(w.r.Storer, ref.Hash(), head.Hash())
+ if err != nil {
+ return err
+ }
+
+ if !updated && headAheadOfRef {
return NoErrAlreadyUpToDate
}
+
ff, err := isFastForward(w.r.Storer, head.Hash(), ref.Hash())
if err != nil {
return err
diff --git a/worktree_test.go b/worktree_test.go
index c808ebd..59c80af 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -265,6 +265,26 @@ func (s *RepositorySuite) TestPullAdd(c *C) {
c.Assert(branch.Hash().String(), Not(Equals), "6ecf0ef2c2dffb796033e5a02219af86ec6584e5")
}
+func (s *WorktreeSuite) TestPullAlreadyUptodate(c *C) {
+ path := fixtures.Basic().ByTag("worktree").One().Worktree().Root()
+
+ r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{
+ URL: filepath.Join(path, ".git"),
+ })
+
+ c.Assert(err, IsNil)
+
+ w, err := r.Worktree()
+ c.Assert(err, IsNil)
+ err = ioutil.WriteFile(filepath.Join(path, "bar"), []byte("bar"), 0755)
+ c.Assert(err, IsNil)
+ _, err = w.Commit("bar", &CommitOptions{Author: defaultSignature()})
+ c.Assert(err, IsNil)
+
+ err = w.Pull(&PullOptions{})
+ c.Assert(err, Equals, NoErrAlreadyUpToDate)
+}
+
func (s *WorktreeSuite) TestCheckout(c *C) {
fs := memfs.New()
w := &Worktree{