Merge branch 'migrate-disambiguate-references' of github.com:git-lfs/git-lfs into migrate-disambiguate-references

This commit is contained in:
Taylor Blau 2017-11-17 08:12:38 -08:00
commit a48c8f159c
3 changed files with 13 additions and 16 deletions

@ -123,7 +123,7 @@ func includeExcludeRefs(l *log.Logger, args []string) (include, exclude []string
return nil, nil, err
}
include = append(include, ref.String())
include = append(include, ref.Refspec())
}
if hardcore {
@ -143,7 +143,7 @@ func includeExcludeRefs(l *log.Logger, args []string) (include, exclude []string
}
for _, ref := range localRefs {
include = append(include, ref.String())
include = append(include, ref.Refspec())
}
} else {
// Otherwise, if neither --include-ref=<ref> or
@ -156,7 +156,7 @@ func includeExcludeRefs(l *log.Logger, args []string) (include, exclude []string
}
for _, rr := range remoteRefs {
exclude = append(exclude, rr.String())
exclude = append(exclude, rr.Refspec())
}
}

@ -95,12 +95,16 @@ type Ref struct {
Sha string
}
// String implements fmt.Stringer.String and returns the fully-qualified
// reference name (including remote), i.e., for a remote branch called
// 'my-feature' on remote 'origin', this function will return:
// Refspec returns the fully-qualified reference name (including remote), i.e.,
// for a remote branch called 'my-feature' on remote 'origin', this function
// will return:
//
// refs/remotes/origin/my-feature
func (r *Ref) String() string {
func (r *Ref) Refspec() string {
if r == nil {
return ""
}
prefix, ok := r.Type.Prefix()
if ok {
return fmt.Sprintf("%s/%s", prefix, r.Name)
@ -387,14 +391,7 @@ func UpdateRef(ref *Ref, to []byte, reason string) error {
// reflog entry, if a "reason" was provided). It operates within the given
// working directory "wd". It returns an error if any were encountered.
func UpdateRefIn(wd string, ref *Ref, to []byte, reason string) error {
var refspec string
if prefix, ok := ref.Type.Prefix(); ok {
refspec = fmt.Sprintf("%s/%s", prefix, ref.Name)
} else {
refspec = ref.Name
}
args := []string{"update-ref", refspec, hex.EncodeToString(to)}
args := []string{"update-ref", ref.Refspec(), hex.EncodeToString(to)}
if len(reason) > 0 {
args = append(args, "-m", reason)
}

@ -47,7 +47,7 @@ func TestRefString(t *testing.T) {
Sha: sha,
},
} {
assert.Equal(t, s, r.String())
assert.Equal(t, s, r.Refspec())
}
}