From 37923577e345babd9e21382449147053ed063f44 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 2 Aug 2017 18:38:32 +0100 Subject: directory handling: dgit: Introduce dgit_privdir and use it This removes another pile of open-coded references to .git/ Signed-off-by: Ian Jackson --- dgit | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'dgit') diff --git a/dgit b/dgit index bc8274f..0ef27f0 100755 --- a/dgit +++ b/dgit @@ -277,6 +277,10 @@ sub gbp_pq { return opts_opt_multi_cmd @gbp_pq; } +sub dgit_privdir () { + our $dgit_privdir_made //= ensure_a_playground 'dgit'; +} + #---------- remote protocol support, common ---------- # remote push initiator/responder protocol: @@ -980,8 +984,8 @@ sub commit_getclogp ($) { our %commit_getclogp_memo; my $memo = $commit_getclogp_memo{$objid}; return $memo if $memo; - mkpath '.git/dgit'; - my $mclog = ".git/dgit/clog-$objid"; + + my $mclog = dgit_privdir()."clog-$objid"; runcmd shell_cmd "exec >$mclog", @git, qw(cat-file blob), "$objid:debian/changelog"; $commit_getclogp_memo{$objid} = parsechangelog("-l$mclog"); @@ -1672,6 +1676,7 @@ our ($dsc_distro, $dsc_hint_tag, $dsc_hint_url); sub prep_ud () { + dgit_privdir(); # ensures that $dgit_privdir_made is based on $maindir fresh_playground 'dgit/unpack'; } @@ -3163,7 +3168,7 @@ END my $author = clogp_authline $useclogp; my $cversion = getfield $useclogp, 'Version'; - my $mcf = ".git/dgit/mergecommit"; + my $mcf = dgit_privdir()."/mergecommit"; open MC, ">", $mcf or die "$mcf $!"; print MC <", $pmf or die "$pmf $!"; print MC <$clogpfn", qw(dpkg-parsechangelog); responder_send_file('parsed-changelog', $clogpfn); @@ -4296,7 +4299,7 @@ END } my @tagwants = push_tagwants($cversion, $dgithead, $maintviewhead, - ".git/dgit/tag"); + dgit_privdir()."/tag"); my @tagobjfns; supplementary_message(<<'END'); @@ -4820,7 +4823,7 @@ sub quiltify_dpkg_commit ($$$;$) { my ($patchname,$author,$msg, $xinfo) = @_; $xinfo //= ''; - mkpath '.git/dgit'; + mkpath '.git/dgit'; # we are in playtree my $descfn = ".git/dgit/quilt-description.tmp"; open O, '>', $descfn or die "$descfn: $!"; $msg =~ s/\n+/\n\n/; @@ -5351,7 +5354,7 @@ END changedir $maindir; runcmd_ordryrun_local - @git, qw(pull --ff-only -q .git/dgit/unpack/work master); + @git, qw(pull --ff-only -q), "$playground/work", qw(master); } sub quilt_fixup_mkwork ($) { @@ -6068,12 +6071,13 @@ sub cmd_gbp_build { push @cmd, (qw(-us -uc --git-no-sign-tags), "--git-builder=@dbp"); if ($gbp_make_orig) { - ensuredir '.git/dgit'; - my $ok = '.git/dgit/origs-gen-ok'; + my $priv = dgit_privdir(); + my $ok = "$priv/origs-gen-ok"; unlink $ok or $!==&ENOENT or die $!; my @origs_cmd = @cmd; push @origs_cmd, qw(--git-cleaner=true); - push @origs_cmd, "--git-prebuild=touch $ok .git/dgit/no-such-dir/ok"; + push @origs_cmd, "--git-prebuild=". + "touch ".(shellquote $ok)." ".(shellquote "$priv/no-such-dir/ok"); push @origs_cmd, @ARGV; if (act_local()) { debugcmd @origs_cmd; -- cgit v1.2.3