X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=git-debrebase;h=70808da019922f01d4fb0f77bb5748d1d7647197;hb=8900e2002df925ebdf4941d18094fc5ca408e027;hp=2f34029a996e3cbeff566806e93789832a67489a;hpb=86dffe037bfbd0f84818a14b1ff41f9cd744dfe8;p=dgit.git diff --git a/git-debrebase b/git-debrebase index 2f34029a..70808da0 100755 --- a/git-debrebase +++ b/git-debrebase @@ -98,13 +98,17 @@ sub badusage ($) { die "bad usage: $m\n"; } -sub cfg ($) { - my ($k) = @_; +sub cfg ($;$) { + my ($k, $optional) = @_; $/ = "\0"; my @cmd = qw(git config -z); push @cmd, qw(--get-all) if wantarray; push @cmd, $k; - my $out = cmdoutput @cmd; + my $out = cmdoutput_errok @cmd; + if (!defined $out) { + fail "missing required git config $k" unless $optional; + return (); + } return split /\0/, $out; } @@ -791,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) = @_; @@ -838,7 +845,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 $!; @@ -864,13 +871,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 { @@ -897,7 +904,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 { @@ -905,17 +912,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 $!; @@ -923,7 +932,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 @@ -1101,6 +1109,17 @@ END # now it's for the user to sort out } +sub cmd_record_ffq_prev () { + badusage "no arguments allowed" if @ARGV; + my ($status, $msg) = record_ffq_prev(); + if ($status eq 'exists' && $opt_noop_ok) { + print "Previous head already recorded\n" or die $!; + } elsif ($status eq 'written') { + } else { + fail "Could not preserve: $msg"; + } +} + sub cmd_gbp2debrebase () { badusage "needs 1 optional argument, the upstream" unless @ARGV<=1; my ($upstream_spec) = @ARGV; @@ -1163,7 +1182,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';