chiark / gitweb /
Report chdir actions in debugging output.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Oct 2013 15:24:54 +0000 (16:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 22 Oct 2013 15:24:54 +0000 (16:24 +0100)
debian/changelog
dgit

index ec5ae868ee7c44fcf2b106daaf158204c8eb4969..5b350d01a16e3ee655cbc381f25475927d051977 100644 (file)
@@ -3,6 +3,7 @@ dgit (0.17~experimental1) experimental; urgency=low
   * Fix dgit --damp-run sbuild to actually work.
   * Improvements to implementation of --dry-run and --damp-run.
   * More fixes to remote implementation.
+  * Report chdir actions in debugging output.
 
  -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Tue, 22 Oct 2013 15:11:19 +0100
 
diff --git a/dgit b/dgit
index 549b2515f0a5633077320bbf755b26b3b9c3c50d..d31b9b1db9d306338896fa6dfae01a4b719fd672 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -133,6 +133,12 @@ sub fetchspec () {
     return  "+".rrref().":".lrref();
 }
 
+sub changedir ($) {
+    my ($newdir) = @_;
+    printdebug "CD $newdir\n";
+    chdir $newdir or die "chdir: $newdir: $!";
+}
+
 #---------- remote protocol support, common ----------
 
 # remote push initiator/responder protocol:
@@ -714,7 +720,7 @@ sub mktree_in_ud_from_only_subdir () {
     die unless @dirs==1;
     $dirs[0] =~ m#^([^/]+)/\.$# or die;
     my $dir = $1;
-    chdir $dir or die "$dir $!";
+    changedir $dir;
     fail "source package contains .git directory" if stat '.git';
     die $! unless $!==&ENOENT;
     runcmd qw(git init -q);
@@ -781,7 +787,7 @@ sub clogp_authline ($) {
 
 sub generate_commit_from_dsc () {
     prep_ud();
-    chdir $ud or die $!;
+    changedir $ud;
     my @files;
     foreach my $f (dsc_files()) {
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
@@ -847,7 +853,7 @@ END
            $outputhash = $lastpush_hash;
        }
     }
-    chdir '../../../..' or die $!;
+    changedir '../../../..';
     runcmd @git, qw(update-ref -m),"dgit fetch import $cversion",
             'DGIT_ARCHIVE', $outputhash;
     cmdoutput @git, qw(log -n2), $outputhash;
@@ -1021,7 +1027,7 @@ sub clone ($) {
     canonicalise_suite();
     badusage "dry run makes no sense with clone" unless act_local();
     mkdir $dstdir or die "$dstdir $!";
-    chdir "$dstdir" or die "$dstdir $!";
+    changedir $dstdir;
     runcmd @git, qw(init -q);
     runcmd @git, qw(config), "remote.$remotename.fetch", fetchspec();
     open H, "> .git/HEAD" or die $!;
@@ -1213,11 +1219,11 @@ sub dopush () {
        commit_quilty_patch();
     }
     check_not_dirty();
-    chdir $ud or die $!;
+    changedir $ud;
     progress "checking that $dscfn corresponds to HEAD";
     runcmd qw(dpkg-source -x --), "../../../../$dscfn";
     my ($tree,$dir) = mktree_in_ud_from_only_subdir();
-    chdir '../../../..' or die $!;
+    changedir '../../../..';
     my @diffcmd = (@git, qw(diff --exit-code), $tree);
     printcmd \*DEBUG,$debugprefix."+",@diffcmd;
     $!=0; $?=0;
@@ -1410,7 +1416,7 @@ sub cmd_remote_push_responder {
     @ARGV = @ARGV[$nrargs..$#ARGV];
     die unless @rargs;
     my ($dir) = @rargs;
-    chdir $dir or die "$dir: $!";
+    changedir $dir;
     $we_are_responder = 1;
     $debugprefix = ' ';
     autoflush STDOUT 1;
@@ -1423,7 +1429,7 @@ our $i_tmp;
 sub i_cleanup {
     local ($@);
     return unless defined $i_tmp;
-    chdir "/" or die $!;
+    changedir "/";
     eval { rmtree $i_tmp; };
 }
 
@@ -1454,7 +1460,7 @@ sub cmd_rpush {
     eval {
        $i_tmp = tempdir();
        my $pid = open2(\*RO, \*RI, @cmd);
-       chdir $i_tmp or die "$i_tmp $!";
+       changedir $i_tmp;
        initiator_expect { m/^dgit-remote-push-ready/ };
        for (;;) {
            my ($icmd,$iargs) = initiator_expect {
@@ -1667,9 +1673,9 @@ sub build_source {
        }
        my $pwd = cmdoutput qw(env - pwd);
        my $leafdir = basename $pwd;
-       chdir ".." or die $!;
+       changedir "..";
        runcmd_ordryrun_local @dpkgsource, qw(-b --), $leafdir;
-       chdir $pwd or die $!;
+       changedir $pwd;
        runcmd_ordryrun_local qw(sh -ec),
            'exec >$1; shift; exec "$@"','x',
            "../$sourcechanges",
@@ -1685,7 +1691,7 @@ sub cmd_build_source {
 
 sub cmd_sbuild {
     build_source();
-    chdir ".." or die $!;
+    changedir "..";
     my $pat = "${package}_".(stripepoch $version)."_*.changes";
     if (act_local()) {
        stat $dscfn or fail "$dscfn (in parent directory): $!";