summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit32
1 files changed, 18 insertions, 14 deletions
diff --git a/dgit b/dgit
index f571933..6fd8f7d 100755
--- a/dgit
+++ b/dgit
@@ -177,6 +177,13 @@ sub changedir ($) {
chdir $newdir or die "chdir: $newdir: $!";
}
+sub stat_exists ($) {
+ my ($f) = @_;
+ return 1 if stat $f;
+ return 0 if $!==&ENOENT;
+ die "stat $f: $!";
+}
+
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
@@ -976,7 +983,7 @@ sub mktree_in_ud_from_only_subdir () {
$dirs[0] =~ m#^([^/]+)/\.$# or die;
my $dir = $1;
changedir $dir;
- fail "source package contains .git directory" if stat '.git';
+ fail "source package contains .git directory" if stat_exists '.git';
die $! unless $!==&ENOENT;
runcmd qw(git init -q);
rmtree('.git/objects');
@@ -1140,11 +1147,9 @@ sub complete_file_from_dsc ($$) {
my $tf = "$dstdir/$f";
my $downloaded = 0;
- if (stat $tf) {
+ if (stat_exists $tf) {
progress "using existing $f";
} else {
- die "$tf $!" unless $!==&ENOENT;
-
my $furl = $dscurl;
$furl =~ s{/[^/]+$}{};
$furl .= "/$f";
@@ -1490,7 +1495,7 @@ sub dopush () {
push_parse_changelog("$clogpfn");
my $dscpath = "$buildproductsdir/$dscfn";
- stat $dscpath or
+ stat_exists $dscpath or
fail "looked for .dsc $dscfn, but $!;".
" maybe you forgot to build";
@@ -1535,10 +1540,9 @@ sub dopush () {
if (!$changesfile) {
my $multi = "$buildproductsdir/".
"${package}_".(stripepoch $cversion)."_multi.changes";
- if (stat "$multi") {
+ if (stat_exists "$multi") {
$changesfile = $multi;
} else {
- $!==&ENOENT or die "$multi: $!";
my $pat = "${package}_".(stripepoch $cversion)."_*.changes";
my @cs = glob "$buildproductsdir/$pat";
fail "failed to find unique changes file".
@@ -1621,10 +1625,8 @@ sub cmd_clone {
}
$dstdir ||= "$package";
- if (stat $dstdir) {
+ if (stat_exists $dstdir) {
fail "$dstdir already exists";
- } elsif ($! != &ENOENT) {
- die "$dstdir: $!";
}
my $cwd_remove;
@@ -1848,7 +1850,8 @@ sub i_resp_file ($) {
my ($keyword) = @_;
my $localname = i_method "i_localname", $keyword;
my $localpath = "$i_tmp/$localname";
- stat $localpath and badproto \*RO, "file $keyword ($localpath) twice";
+ stat_exists $localpath and
+ badproto \*RO, "file $keyword ($localpath) twice";
protocol_receive_file \*RO, $localpath;
i_method "i_file", $keyword;
}
@@ -2118,8 +2121,9 @@ sub cmd_sbuild {
changedir "..";
my $pat = "${package}_".(stripepoch $version)."_*.changes";
if (act_local()) {
- stat $dscfn or fail "$dscfn (in parent directory): $!";
- stat $sourcechanges or fail "$sourcechanges (in parent directory): $!";
+ stat_exist $dscfn or fail "$dscfn (in parent directory): $!";
+ stat_exists $sourcechanges
+ or fail "$sourcechanges (in parent directory): $!";
foreach my $cf (glob $pat) {
next if $cf eq $sourcechanges;
unlink $cf or fail "remove $cf: $!";
@@ -2136,7 +2140,7 @@ sub cmd_sbuild {
runcmd_ordryrun_local @mergechanges, @changesfiles;
my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
if (act_local()) {
- stat $multichanges or fail "$multichanges: $!";
+ stat_exists $multichanges or fail "$multichanges: $!";
}
printdone "build successful, results in $multichanges\n" or die $!;
}