chiark / gitweb /
dgit: Do not fail when run with detached HEAD. Closes:#853022.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Feb 2017 14:41:43 +0000 (14:41 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Feb 2017 14:41:44 +0000 (14:41 +0000)
Specifically:

* Pass -q to git-symbolic-ref.  That means that it doesn't print
  an error message when HEAD is not a symbolic ref (ie, a
  detached head), and it means that the exit status is then 1
  rather than 128.

* If the return value from cmdoutput_errok is undef, check $? (which
  is the exit status <<8) and then simply pass on the undef.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
debian/changelog
dgit

index 68fb46e0628e9c29c5d0d5a28d0f5c54b3ab8729..a63f27db2bdcc91192dcf83fca6c0ccc7bfb01db 100644 (file)
@@ -5,6 +5,7 @@ dgit (3.10~) unstable; urgency=medium
     to dgit private workarea.  Closes:#853085.
   * dgit: Strip initial newline from Changes line from dpkg-parsechangelog
     so as to avoid blank line in commit messages.  Closes:#853093.
+  * dgit: Do not fail when run with detached HEAD.  Closes:#853022.
 
   Test suite:
   * quilt-useremail: New test for user config copying (#853085).
diff --git a/dgit b/dgit
index f1f9332a814f0e277fe13391e064044b5b67b270..724dba10ef557e79a9ad2ebb1ec47ccb5f82f917 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -4435,8 +4435,12 @@ sub cmd_clone {
 }
 
 sub branchsuite () {
-    my @cmd = (@git, qw(symbolic-ref HEAD));
+    my @cmd = (@git, qw(symbolic-ref -q HEAD));
     my $branch = cmdoutput_errok @cmd;
+    if (!defined $branch) {
+       $?==256 or failedcmd @cmd;
+       return undef;
+    }
     if ($branch =~ m#$lbranch_re#o) {
        return $1;
     } else {