return $l;
}
+sub git_dir () {
+ our $git_dir;
+ if (!defined $git_dir) {
+ $git_dir = run_git_1line(qw(rev-parse --git-dir));
+ }
+ return $git_dir;
+}
+
sub current_tb_branch () {
- my ($estatus,$ref) =
- run_git_1line({ ExitStatus=>1 }, qw(symbolic-ref HEAD));
- if ($estatus == 256) {
+ open R, git_dir().'/HEAD' or die "open HEAD $!";
+ my $ref = <R>; defined $ref or die $!;
+ close R;
+ chomp $ref or die;
+ if ($ref !~ s#^ref: ##) {
return {
- Kind => 'detached'
+ Kind => 'detached',
+ Ref => $ref,
};
}
- die "$estatus ?" if $estatus;
if ($ref =~ m#^refs/topbloke-(tip|base)s/([^/\@]*)\@([^/\@]*)/([^/]*)/#) {
return {
Kind => $1,
die "cannot make branch starting at base of another;".
" check out a real branch\n" if $current->{Kind} eq 'base';
-die "strange branch ref, making new branch with this as dep is unwise\n"
- if $current->{Kind} eq 'weird';
+die "strange branch ref $current->{Kind} $current->{Ref},\n".
+ " making new branch with this as dep is unwise\n"
+ unless ($current->{Kind} eq 'foreign' ||
+ $current->{Kind} eq 'tip');
sub fillin ($$$) {
my ($key, $newval, $what) = @_;