chiark / gitweb /
git-debpush: Check for a detached head when pushing HEAD
authorSean Whitton <spwhitton@spwhitton.name>
Mon, 22 Jul 2019 15:17:34 +0000 (16:17 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 22 Jul 2019 16:08:51 +0000 (17:08 +0100)
See discussion in #932612.

Suggested-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
git-debpush
git-debpush.1.pod

index 402b1dd6a14d5b13df45fb488f36520acbcf6319..c3b067dca4eff7feb0edab1812c33694f3e29e5e 100755 (executable)
@@ -230,6 +230,14 @@ case "$quilt_mode" in
     *) badusage "invalid quilt mode: $quilt_mode" ;;
 esac
 
+# **** Early sanity check ****
+
+if [ "$branch" = "HEAD" ] \
+       && ! git symbolic-ref --quiet HEAD >/dev/null; then
+    fail_check detached \
+               "HEAD is detached; you probably don't want to debpush it"
+fi
+
 # **** Gather git information ****
 
 remoteconfigs=()
index b9a908efe44b6d7800a922550f74210f92b2be38..5e40e3c854c0aeaeb34dc5b07604c0c5ca1ddb20 100644 (file)
@@ -243,6 +243,12 @@ git-debrebase(1) branch in an unstitched state (see git-debrebase(5)).
 
 =back
 
+=item B<detached>
+
+Ignore the fact that HEAD is to be tagged, but HEAD is detached (this
+check is only run when B<--branch=HEAD> or no B<--branch> option is
+specified).
+
 =back
 
 =head1 SEE ALSO