aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.go
diff options
context:
space:
mode:
authorMathias Rüdiger <ruediger@blueboot.org>2020-06-22 09:09:19 +0200
committerMathias Rüdiger <ruediger@blueboot.org>2020-06-22 09:09:19 +0200
commit23e21f0cfc6196d5dce8fc20af0ecc9701aabe4f (patch)
tree4a8c9ab3e3ef1676e4cf120beb7e25aac8855b05 /worktree.go
parent16918a5be9a2076bbb686b2580da1988d557da6d (diff)
downloadgo-git-23e21f0cfc6196d5dce8fc20af0ecc9701aabe4f.tar.gz
Report "Already up to date" when local repository ahead of remote
If you run 'git pull', do a commit and run 'git pull' again git will report "Already up to date" whereas go-git would report a reports non-fast-forward update. This commit changes the behavior of go-git to match that of git.
Diffstat (limited to 'worktree.go')
-rw-r--r--worktree.go8
1 files changed, 7 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