chiark / gitweb /
git-debrebase: fix $/ to be local in cfg (!)
[dgit.git] / git-debrebase
index 726c7be8a75d7b3d13feefb78e1d5d7a3c50cbc2..f68dfb1ae2ee674324e03dab36ec0619e95ba5d6 100755 (executable)
@@ -100,7 +100,7 @@ sub badusage ($) {
 
 sub cfg ($;$) {
     my ($k, $optional) = @_;
-    $/ = "\0";
+    local $/ = "\0";
     my @cmd = qw(git config -z);
     push @cmd, qw(--get-all) if wantarray;
     push @cmd, $k;
@@ -795,7 +795,10 @@ sub walk ($;$$) {
     return @r
 }
 
-sub get_head () { return git_rev_parse qw(HEAD); }
+sub get_head () {
+    git_check_unmodified();
+    return git_rev_parse qw(HEAD);
+}
 
 sub update_head ($$$) {
     my ($old, $new, $mrest) = @_;
@@ -831,7 +834,6 @@ sub defaultcmd_rebase () {
     my $old = get_head();
     my ($tip,$breakwater) = walk $old;
     update_head_postlaunder $old, $tip, 'launder for rebase';
-    @ARGV = qw(-i) unless @ARGV; # make configurable
     runcmd @git, qw(rebase), @ARGV, $breakwater;
 }
 
@@ -842,7 +844,7 @@ sub cmd_analyse () {
     if (defined $old) {
        $old = git_rev_parse $old;
     } else {
-       $old = get_head();
+       $old = git_rev_parse 'HEAD';
     }
     my ($dummy,$breakwater) = walk $old, 1,*STDOUT;
     STDOUT->error and die $!;
@@ -868,13 +870,13 @@ sub record_ffq_prev () {
     my $currentval = get_head();
 
     my $exists = git_get_ref $ffq_prev;
-    return ('exists',"$ffq_prev already exists") if defined $exists;
+    return ('exists',"$ffq_prev already exists") if $exists;
 
     return ('not-branch', 'HEAD symref is not to refs/heads/')
        unless $current =~ m{^refs/heads/};
     my $branch = $';
 
-    my @check_specs = split /\;/, (cfg "branch.$branch.ffq-ffrefs") // '*';
+    my @check_specs = split /\;/, (cfg "branch.$branch.ffq-ffrefs",1) // '*';
     my %checked;
 
     my $check = sub {
@@ -901,7 +903,7 @@ sub record_ffq_prev () {
        }
     };
 
-    my $merge = cfg "branch.$branch.merge";
+    my $merge = cfg "branch.$branch.merge",1;
     if (defined $merge && $merge =~ m{^refs/heads/}) {
        my $rhs = $';
        my $check_remote = sub {
@@ -909,17 +911,19 @@ sub record_ffq_prev () {
            return unless defined $remote;
            $check->("refs/remotes/$remote/$rhs", $desc);
        };
-       $check_remote->((cfg "branch.$branch.remote"),
+       $check_remote->((cfg "branch.$branch.remote",1),
                        'remote fetch/merge branch');
-       $check_remote->((cfg "branch.$branch.pushRemote") //
-                       (cfg "branch.$branch.pushDefault"),
+       $check_remote->((cfg "branch.$branch.pushRemote",1) //
+                       (cfg "branch.$branch.pushDefault",1),
                        'remote push branch');
     }
     if ($branch =~ m{^dgit/}) {
        $check->("remotes/dgit/$branch", 'remote dgit branch');
+    } elsif ($branch =~ m{^master$}) {
+       $check->("remotes/dgit/dgit/sid", 'remote dgit branch for sid');
     }
 
-    fproblems_maybe_fail();
+    fproblems_maybe_bail();
     runcmd @git, qw(update-ref -m), "record current head for preservation",
        $ffq_prev, $currentval, $git_null_obj;
     print "Recorded current head for preservation\n" or die $!;
@@ -927,7 +931,6 @@ sub record_ffq_prev () {
 }
 
 sub cmd_new_upstream_v0 () {
-    # tree should be clean and this is not checked
     # automatically and unconditionally launders before rebasing
     # if rebase --abort is used, laundering has still been done
 
@@ -1178,7 +1181,7 @@ sub cmd_gbp2debrebase () {
        # rebase the patch queue onto the new breakwater
        runcmd @git, qw(reset --quiet --hard patch-queue/gdr-internal);
        runcmd @git, qw(rebase --quiet --onto), $work, qw(gdr-internal);
-       $work = get_head();
+       $work = git_rev_parse 'HEAD';
     };
 
     update_head_checkout $old_head, $work, 'gbp2debrebase';