chiark / gitweb /
git-debrebase: make cfg optionally take $optional (nfc)
[dgit.git] / git-debrebase
index 2f34029a996e3cbeff566806e93789832a67489a..726c7be8a75d7b3d13feefb78e1d5d7a3c50cbc2 100755 (executable)
@@ -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;
 }
 
@@ -1101,6 +1105,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;