From 1db770da2b41b1ed02061f5145a2d8abc6e9c22c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 22 Jul 2019 16:17:34 +0100 Subject: git-debpush: Check for a detached head when pushing HEAD See discussion in #932612. Suggested-by: Ian Jackson Signed-off-by: Sean Whitton --- git-debpush | 8 ++++++++ git-debpush.1.pod | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/git-debpush b/git-debpush index 402b1dd..c3b067d 100755 --- a/git-debpush +++ b/git-debpush @@ -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=() diff --git a/git-debpush.1.pod b/git-debpush.1.pod index b9a908e..5e40e3c 100644 --- a/git-debpush.1.pod +++ b/git-debpush.1.pod @@ -243,6 +243,12 @@ git-debrebase(1) branch in an unstitched state (see git-debrebase(5)). =back +=item B + +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 -- cgit v1.2.3