aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-11-29 12:22:37 +0100
committerGitHub <noreply@github.com>2017-11-29 12:22:37 +0100
commitc07c778ed043429427533e2fd7549a3d54b903f1 (patch)
tree9fbd8da724791193905635a4ed789c6ddf8f39c5 /repository.go
parent6dda959c4bda3a422a9a1c6425f92efa914c4d82 (diff)
parentcbab840ef28888c2e85112b3b48294f7333ec187 (diff)
downloadgo-git-c07c778ed043429427533e2fd7549a3d54b903f1.tar.gz
Merge pull request #665 from keybase/strib/gh-fast-forward-fetch
remote: support for non-force, fast-forward-only fetches
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/repository.go b/repository.go
index 230b3e5..fd6f6d1 100644
--- a/repository.go
+++ b/repository.go
@@ -625,9 +625,9 @@ func (r *Repository) calculateRemoteHeadReference(spec []config.RefSpec,
return refs
}
-func updateReferenceStorerIfNeeded(
- s storer.ReferenceStorer, r *plumbing.Reference) (updated bool, err error) {
-
+func checkAndUpdateReferenceStorerIfNeeded(
+ s storer.ReferenceStorer, r, old *plumbing.Reference) (
+ updated bool, err error) {
p, err := s.Reference(r.Name())
if err != nil && err != plumbing.ErrReferenceNotFound {
return false, err
@@ -635,7 +635,7 @@ func updateReferenceStorerIfNeeded(
// we use the string method to compare references, is the easiest way
if err == plumbing.ErrReferenceNotFound || r.String() != p.String() {
- if err := s.SetReference(r); err != nil {
+ if err := s.CheckAndSetReference(r, old); err != nil {
return false, err
}
@@ -645,6 +645,11 @@ func updateReferenceStorerIfNeeded(
return false, nil
}
+func updateReferenceStorerIfNeeded(
+ s storer.ReferenceStorer, r *plumbing.Reference) (updated bool, err error) {
+ return checkAndUpdateReferenceStorerIfNeeded(s, r, nil)
+}
+
// Fetch fetches references along with the objects necessary to complete
// their histories, from the remote named as FetchOptions.RemoteName.
//