make the output of ‘gm’ slightly less confusing if already on ‘main’
- ID
0d9491c- date
2023-05-15 19:54:35+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
c6962f8- message
make the output of 'gm' slightly less confusing if already on 'main'- changed files
1 file, 11 additions, 1 deletion
Changed files
git/gm (158) → git/gm (414)
diff --git a/git/gm b/git/gm
index b190918..f0d7a04 100755
--- a/git/gm
+++ b/git/gm
@@ -4,5 +4,15 @@
set -o errexit
set -o nounset
-git checkout "$(_get_primary_branch)"
+# Checking for the branch first is a bit slower, but avoids a potentially
+# confusing warning immediately before the pull:
+#
+# Already on 'main'
+# Your branch is up to date with 'origin/main'.
+#
+if [[ $(gcb) != $(_get_primary_branch) ]]
+then
+ git checkout "$(_get_primary_branch)"
+fi
+
gp