aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/reference.go
diff options
context:
space:
mode:
authorPaulo Gomes <pjbgf@linux.com>2023-05-25 09:46:00 +0100
committerGitHub <noreply@github.com>2023-05-25 09:46:00 +0100
commit8bcb67c2cb09f9cf2fd0b0765c6cfcbc6355321a (patch)
treeb5a0c837eb3afe02cb8f24d85846c6464616f655 /plumbing/reference.go
parentb98b813a17d32f4fa29a3ef2e9f4c38c5a97b440 (diff)
parent65a5c716353f81b20c70f4a2c6560590d9472b6e (diff)
downloadgo-git-8bcb67c2cb09f9cf2fd0b0765c6cfcbc6355321a.tar.gz
Merge pull request #762 from AriehSchneier/fetch-non-qualified
git: enable fetch with unqualified references
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