summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2019-07-22 16:17:34 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2019-07-22 17:08:51 +0100
commit1db770da2b41b1ed02061f5145a2d8abc6e9c22c (patch)
treeb30bb6b8cd376454e8b90cad520ef7823f49fc9a
parentd859eec10fe463619069a01f4489b2a11af31fab (diff)
git-debpush: Check for a detached head when pushing HEAD
See discussion in #932612. Suggested-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rwxr-xr-xgit-debpush8
-rw-r--r--git-debpush.1.pod6
2 files changed, 14 insertions, 0 deletions
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<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