aboutsummaryrefslogtreecommitdiff
path: root/ref/refname/root.go
diff options
context:
space:
mode:
Diffstat (limited to 'ref/refname/root.go')
-rw-r--r--ref/refname/root.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/ref/refname/root.go b/ref/refname/root.go
new file mode 100644
index 00000000..43361846
--- /dev/null
+++ b/ref/refname/root.go
@@ -0,0 +1,21 @@
+package refname
+
+import "strings"
+
+// IsRoot reports whether name is one root ref according to Git.
+func IsRoot(name string) bool {
+ if !IsRootSyntax(name) || IsPseudo(name) {
+ return false
+ }
+
+ if strings.HasSuffix(name, "_HEAD") {
+ return true
+ }
+
+ switch name {
+ case "HEAD", "AUTO_MERGE", "BISECT_EXPECTED_REV", "NOTES_MERGE_PARTIAL", "NOTES_MERGE_REF", "MERGE_AUTOSTASH":
+ return true
+ default:
+ return false
+ }
+}