aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/reference.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/reference.go')
-rw-r--r--plumbing/reference.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/plumbing/reference.go b/plumbing/reference.go
index aeb4227..5a67f69 100644
--- a/plumbing/reference.go
+++ b/plumbing/reference.go
@@ -15,10 +15,11 @@ const (
symrefPrefix = "ref: "
)
-// RefRevParseRules are a set of rules to parse references into short names.
-// These are the same rules as used by git in shorten_unambiguous_ref.
+// RefRevParseRules are a set of rules to parse references into short names, or expand into a full reference.
+// These are the same rules as used by git in shorten_unambiguous_ref and expand_ref.
// See: https://github.com/git/git/blob/e0aaa1b6532cfce93d87af9bc813fb2e7a7ce9d7/refs.c#L417
var RefRevParseRules = []string{
+ "%s",
"refs/%s",
"refs/tags/%s",
"refs/heads/%s",
@@ -113,7 +114,7 @@ func (r ReferenceName) String() string {
func (r ReferenceName) Short() string {
s := string(r)
res := s
- for _, format := range RefRevParseRules {
+ for _, format := range RefRevParseRules[1:] {
_, err := fmt.Sscanf(s, format, &res)
if err == nil {
continue