aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gitalias/git-sw.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/gitalias/git-sw.go')
-rw-r--r--src/gitalias/git-sw.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/gitalias/git-sw.go b/src/gitalias/git-sw.go
index 78f7397..5c098a1 100644
--- a/src/gitalias/git-sw.go
+++ b/src/gitalias/git-sw.go
@@ -51,7 +51,23 @@ func requiresDetachFlag(argv []string) bool {
return false
}
firstArg := argv[1]
- return strings.HasPrefix(firstArg, "origin/") || strings.HasPrefix(firstArg, "upstream/")
+
+ // Example: origin/main, upstream/develop
+ if strings.HasPrefix(firstArg, "origin/") || strings.HasPrefix(firstArg, "upstream/") {
+ return true
+ }
+
+ // Example: 1234, cafebabe
+ if len(firstArg) >= 4 {
+ for _, c := range firstArg {
+ if !unicode.Is(unicode.ASCII_Hex_Digit, c) {
+ return false
+ }
+ }
+ return true
+ }
+
+ return false
}
func isInt(s string) bool {