chiark / gitweb /
directory handling: dgit: Use $maindir rather than ../../..
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 2 Aug 2017 15:46:37 +0000 (16:46 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Aug 2017 08:57:52 +0000 (09:57 +0100)
Replace all the open-coded ../.. constructs with references to
$maindir.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 1db14307ab8a65011a77f85edb60048c5551c619..bc8274ff426f591b1a7d81a82e6a1b3c7b8769ca 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1709,8 +1709,8 @@ sub remove_stray_gits ($) {
 
 sub mktree_in_ud_from_only_subdir ($;$) {
     my ($what,$raw) = @_;
 
 sub mktree_in_ud_from_only_subdir ($;$) {
     my ($what,$raw) = @_;
-
     # changes into the subdir
     # changes into the subdir
+
     my (@dirs) = <*/.>;
     die "expected one subdir but found @dirs ?" unless @dirs==1;
     $dirs[0] =~ m#^([^/]+)/\.$# or die;
     my (@dirs) = <*/.>;
     die "expected one subdir but found @dirs ?" unless @dirs==1;
     $dirs[0] =~ m#^([^/]+)/\.$# or die;
@@ -2057,7 +2057,7 @@ sub generate_commits_from_dsc () {
     foreach my $fi (@dfi) {
        my $f = $fi->{Filename};
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
     foreach my $fi (@dfi) {
        my $f = $fi->{Filename};
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
-       my $upper_f = "../../../../$f";
+       my $upper_f = "$maindir/../$f";
 
        printdebug "considering reusing $f: ";
 
 
        printdebug "considering reusing $f: ";
 
@@ -2376,6 +2376,10 @@ END
        local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
 
        my $path = $ENV{PATH} or die;
        local $ENV{GIT_AUTHOR_DATE} =  $authline[2];
 
        my $path = $ENV{PATH} or die;
+       
+       # we use ../../gbp-pq-output, which (given that we are in
+       # $playground/PLAYTREE, and $playground is .git/dgit/unpack,
+       # is .git/dgit.
 
        foreach my $use_absurd (qw(0 1)) {
            runcmd @git, qw(checkout -q unpa);
 
        foreach my $use_absurd (qw(0 1)) {
            runcmd @git, qw(checkout -q unpa);
@@ -3731,7 +3735,7 @@ sub maybe_split_brain_save ($$$) {
     my ($headref, $dgitview, $msg) = @_;
     # => message fragment "$saved" describing disposition of $dgitview
     return "commit id $dgitview" unless defined $split_brain_save;
     my ($headref, $dgitview, $msg) = @_;
     # => message fragment "$saved" describing disposition of $dgitview
     return "commit id $dgitview" unless defined $split_brain_save;
-    my @cmd = (shell_cmd "cd ../../../..",
+    my @cmd = (shell_cmd 'cd "$1"; shift', $maindir,
               @git, qw(update-ref -m),
               "dgit --dgit-view-save $msg HEAD=$headref",
               $split_brain_save, $dgitview);
               @git, qw(update-ref -m),
               "dgit --dgit-view-save $msg HEAD=$headref",
               $split_brain_save, $dgitview);
@@ -4217,7 +4221,7 @@ END
     changedir $playground;
     progress "checking that $dscfn corresponds to HEAD";
     runcmd qw(dpkg-source -x --),
     changedir $playground;
     progress "checking that $dscfn corresponds to HEAD";
     runcmd qw(dpkg-source -x --),
-        $dscpath =~ m#^/# ? $dscpath : "../../../$dscpath";
+        $dscpath =~ m#^/# ? $dscpath : "$maindir/$dscpath";
     my ($tree,$dir) = mktree_in_ud_from_only_subdir("source package");
     check_for_vendor_patches() if madformat($dsc->{format});
     changedir $maindir;
     my ($tree,$dir) = mktree_in_ud_from_only_subdir("source package");
     check_for_vendor_patches() if madformat($dsc->{format});
     changedir $maindir;
@@ -5363,7 +5367,7 @@ sub quilt_fixup_linkorigs ($$) {
     my ($upstreamversion, $fn) = @_;
     # calls $fn->($leafname);
 
     my ($upstreamversion, $fn) = @_;
     # calls $fn->($leafname);
 
-    foreach my $f (<../../../../*>) { #/){
+    foreach my $f (<$maindir/../*>) { #/){
        my $b=$f; $b =~ s{.*/}{};
        {
            local ($debuglevel) = $debuglevel-1;
        my $b=$f; $b =~ s{.*/}{};
        {
            local ($debuglevel) = $debuglevel-1;
@@ -5442,12 +5446,12 @@ END
                  debian/control debian/changelog);
     foreach my $maybe (qw(debian/patches debian/source/options
                           debian/tests/control)) {
                  debian/control debian/changelog);
     foreach my $maybe (qw(debian/patches debian/source/options
                           debian/tests/control)) {
-        next unless stat_exists "../../../$maybe";
+        next unless stat_exists "$maindir/$maybe";
         push @files, $maybe;
     }
 
     my $debtar= srcfn $fakeversion,'.debian.tar.gz';
         push @files, $maybe;
     }
 
     my $debtar= srcfn $fakeversion,'.debian.tar.gz';
-    runcmd qw(env GZIP=-1n tar -zcf), "./$debtar", qw(-C ../../..), @files;
+    runcmd qw(env GZIP=-1n tar -zcf), "./$debtar", qw(-C), $maindir, @files;
 
     $dscaddfile->($debtar);
     close $fakedsc or die $!;
 
     $dscaddfile->($debtar);
     close $fakedsc or die $!;
@@ -5490,7 +5494,7 @@ sub quilt_check_splitbrain_cache ($$) {
     debugcmd "|(probably)",@cmd;
     my $child = open GC, "-|";  defined $child or die $!;
     if (!$child) {
     debugcmd "|(probably)",@cmd;
     my $child = open GC, "-|";  defined $child or die $!;
     if (!$child) {
-       chdir '../../..' or die $!;
+       chdir $maindir or die $!;
        if (!stat ".git/logs/refs/$splitbraincache") {
            $! == ENOENT or die $!;
            printdebug ">(no reflog)\n";
        if (!stat ".git/logs/refs/$splitbraincache") {
            $! == ENOENT or die $!;
            printdebug ">(no reflog)\n";