chiark / gitweb /
dgit: config handling: better debugging
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 775e03ccd6ac01ee64232a820dee6a343b52ed14..ee1101da23a4521f3d9d5ac33e59b0b2c37cd248 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -664,6 +664,7 @@ sub git_get_config ($) {
     my ($c) = @_;
     foreach my $src (@gitcfgsources) {
        my $l = $gitcfgs{$src}{$c};
+       croak "$l $c" if $l && !ref $l;
        printdebug"C $c ".(defined $l ?
                           join " ", map { messagequote "'$_'" } @$l :
                           "undef")."\n"
@@ -679,6 +680,7 @@ sub git_get_config ($) {
 sub cfg {
     foreach my $c (@_) {
        return undef if $c =~ /RETURN-UNDEF/;
+       printdebug "C? $c\n" if $debuglevel >= 5;
        my $v = git_get_config($c);
        return $v if defined $v;
        my $dv = $defcfg{$c};
@@ -691,7 +693,7 @@ sub cfg {
        "$us: distro or suite appears not to be (properly) supported";
 }
 
-sub access_basedistro () {
+sub access_basedistro__noalias () {
     if (defined $idistro) {
        return $idistro;
     } else {   
@@ -711,6 +713,12 @@ sub access_basedistro () {
     }
 }
 
+sub access_basedistro () {
+    my $noalias = access_basedistro__noalias();
+    my $canon = cfg("dgit-distro.$noalias.alias-canon",'RETURN-UNDEF');
+    return $canon // $noalias;
+}
+
 sub access_nomdistro () {
     my $base = access_basedistro();
     my $r = cfg("dgit-distro.$base.nominal-distro",'RETURN-UNDEF') // $base;
@@ -2769,7 +2777,8 @@ sub resolve_dsc_field_commit ($$) {
     return unless defined $dsc_hash;
 
     my $mapref =
-       $already_distro eq $dsc_distro || !$chase_dsc_distro 
+       defined $already_mapref &&
+       ($already_distro eq $dsc_distro || !$chase_dsc_distro)
        ? $already_mapref : undef;
 
     my $do_fetch;
@@ -6023,11 +6032,15 @@ sub cmd_import_dsc {
     parse_dscdata();
 
     $package = getfield $dsc, 'Source';
-    parse_dsc_field($dsc, "Dgit metadata in .dsc");
 
-    if (defined $dsc_hash
-       && !forceing [qw(import-dsc-with-dgit-field)]) {
+    parse_dsc_field($dsc, "Dgit metadata in .dsc")
+       unless forceing [qw(import-dsc-with-dgit-field)];
+
+    if (defined $dsc_hash) {
        progress "dgit: import-dsc of .dsc with Dgit field, using git hash";
+       resolve_dsc_field_commit undef, undef;
+    }
+    if (defined $dsc_hash) {
        my @cmd = (qw(sh -ec),
                   "echo $dsc_hash | git cat-file --batch-check");
        my $objgot = cmdoutput @cmd;
@@ -6309,6 +6322,11 @@ sub parseopts () {
                # undocumented, for testing
                push @ropts, $_;
                $need_split_build_invocation = 1;
+           } elsif (m/^--config-lookup-explode=(.+)$/s) {
+               # undocumented, for testing
+               push @ropts, $_;
+               $gitcfgs{cmdline}{$1} = 'CONFIG-LOOKUP-EXPLODE';
+               # ^ it's supposed to be an array ref
            } elsif (m/^(--[-0-9a-z]+)(=|$)/ && ($oi = $valopts_long{$1})) {
                $val = $2 ? $' : undef; #';
                $valopt->($oi->{Long});