summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2017-02-05 14:41:43 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2017-02-05 14:41:44 +0000
commit17cbb0b93e661fa2f163b155fd4505b0e4b70647 (patch)
tree5595e768b15e36718b89bde8ccb1fac7e7f0a661 /dgit
parente12f9af0e827a5b953f294a4cc0c7fcab7c21603 (diff)
dgit: Do not fail when run with detached HEAD. Closes:#853022.
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>
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit6
1 files changed, 5 insertions, 1 deletions
diff --git a/dgit b/dgit
index f1f9332..724dba1 100755
--- 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 {