$!=0; $?=0;
{ local $/ = undef; $d = <P>; }
die if P->error;
- close P or return undef;
+ if (!close P) { print DEBUG "=>!$?\n" if $debug>0; return undef; }
chomp $d;
+ $d =~ m/^.*/;
+ print DEBUG "=> \`$&'",(length $' ? '...' : ''),"\n" if $debug>0; #';
return $d;
}
$v = cmdoutput_errok(@git, qw(config --), $c);
};
if ($?==0) {
- chomp $v;
return $v;
} elsif ($?!=256) {
die "$c $?";
symlink '../../../../objects','.git/objects' or die $!;
runcmd @git, qw(add -Af);
my $tree = cmdoutput @git, qw(write-tree);
- chomp $tree; $tree =~ m/^\w+$/ or die "$tree ?";
+ $tree =~ m/^\w+$/ or die "$tree ?";
return ($tree,$dir);
}
m/\.orig(?:-\w+)?\.tar\.\w+$/;
}
+sub make_commit ($) {
+ my ($file) = @_;
+ return cmdoutput @git, qw(hash-object -w -t commit), $file;
+}
+
sub generate_commit_from_dsc () {
prep_ud();
chdir $ud or die $!;
my $authline = "$author $date";
$authline =~ m/^[^<>]+ \<\S+\> \d+ [-+]\d+$/ or die $authline;
open C, ">../commit.tmp" or die $!;
- print C "tree $tree\n" or die $!;
- print C "parent $upload_hash\n" or die $! if $upload_hash;
print C <<END or die $!;
+tree $tree
author $authline
committer $authline
$clogp->{Changes}
-# imported by dgit from the archive
+# imported from the archive
END
close C or die $!;
- my $commithash = cmdoutput @git, qw(hash-object -w -t commit ../commit.tmp);
+ my $commithash = make_commit qw(../commit.tmp);
+ if ($upload_hash) {
+ open C, ">../commit2.tmp" or die $!;
+ print C <<END or die $!;
+tree $tree
+parent $upload_hash
+parent $commithash
+author $authline
+committer $authline
+
+Record $package ($clogp->{Version}) in archive suite $suite
+END
+ $commithash = make_commit qw(../commit2.tmp);
+ }
print "synthesised git commit from .dsc $clogp->{Version}\n";
chdir '../../../..' or die $!;
- cmdoutput @git, qw(update-ref -m),"dgit synthesise $clogp->{Version}",
+ cmdoutput @git, qw(update-ref -m),"dgit fetch import $clogp->{Version}",
'DGIT_ARCHIVE', $commithash;
cmdoutput @git, qw(log -n2), $commithash;
# ... gives git a chance to complain if our commit is malformed
print "last upload to archive has NO git hash\n";
}
- $!=0; $upload_hash =
- cmdoutput_errok @git, qw(show-ref --heads), lrref();
- if ($?==0) {
- die unless chomp $upload_hash;
- } elsif ($?==256) {
+ my $lrref_fn = ".git/".lrref();
+ if (open H, $lrref_fn) {
+ $upload_hash = <H>;
+ chomp $upload_hash;
+ die "$lrref_fn $upload_hash ?" unless $upload_hash =~ m/^\w+$/;
+ } elsif ($! == &ENOENT) {
$upload_hash = '';
} else {
- die $?;
+ die "$lrref_fn $!";
}
+ print DEBUG "last upload hash $upload_hash\n";
my $hash;
if (defined $dsc_hash) {
die "missing git history even though dsc has hash"
sub branchsuite () {
my $branch = cmdoutput_errok @git, qw(symbolic-ref HEAD);
- chomp $branch;
if ($branch =~ m#$lbranch_re#o) {
return $1;
} else {