aboutsummaryrefslogtreecommitdiff
path: root/ref/name/root.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-26 09:19:01 +0000
committerGravatar Runxi Yu2026-03-26 09:19:01 +0000
commit929b8cc620abca70b3444b09be5249f6c6cb7812 (patch)
tree29b1edba8f597d09a2a51a6b2c901389cc40e242 /ref/name/root.go
parentformat: Move commitgraph and packfile here (diff)
signatureNo signature
ref/name: Rename from ref/refname
Diffstat (limited to 'ref/name/root.go')
-rw-r--r--ref/name/root.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/ref/name/root.go b/ref/name/root.go
new file mode 100644
index 00000000..43361846
--- /dev/null
+++ b/ref/name/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
+ }
+}