summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Debian/Dgit.pm15
-rw-r--r--debian/changelog1
-rwxr-xr-xdgit9
3 files changed, 17 insertions, 8 deletions
diff --git a/Debian/Dgit.pm b/Debian/Dgit.pm
index abcf123..ebf9d7d 100644
--- a/Debian/Dgit.pm
+++ b/Debian/Dgit.pm
@@ -49,7 +49,7 @@ BEGIN {
failedcmd_report_cmd failedcmd
runcmd cmdoutput cmdoutput_errok
git_rev_parse git_cat_file
- git_get_ref git_for_each_ref
+ git_get_ref git_get_symref git_for_each_ref
git_for_each_tag_referring is_fast_fwd
$package_re $component_re $deliberately_re
$distro_re $versiontag_re $series_filename_re
@@ -381,6 +381,19 @@ sub git_cat_file ($;$) {
return $chk->($type, $data);
}
+sub git_get_symref (;$) {
+ my ($symref) = @_; $symref //= 'HEAD';
+ # => undef if not a symref, otherwise refs/...
+ my @cmd = (qw(git symbolic-ref -q HEAD));
+ my $branch = cmdoutput_errok @cmd;
+ if (!defined $branch) {
+ $?==256 or failedcmd @cmd;
+ } else {
+ chomp $branch;
+ }
+ return $branch;
+}
+
sub git_for_each_ref ($$;$) {
my ($pattern,$func,$gitdir) = @_;
# calls $func->($objid,$objtype,$fullrefname,$reftail);
diff --git a/debian/changelog b/debian/changelog
index 464a433..62d8eed 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ dgit (4.5~) unstable; urgency=medium
Internal changes:
* Move $playground global to dgit.
+ * Break git_get_symref out into Dgit.pm.
--
diff --git a/dgit b/dgit
index 9ce7972..aaafefb 100755
--- a/dgit
+++ b/dgit
@@ -4511,13 +4511,8 @@ sub cmd_clone {
}
sub branchsuite () {
- 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) {
+ my $branch = git_get_symref();
+ if (defined $branch && $branch =~ m#$lbranch_re#o) {
return $1;
} else {
return undef;