chiark / gitweb /
Revert "Dgit: Introduce in_workarea and fresh_workarea"
[dgit.git] / Debian / Dgit.pm
index 3d97848ff2df75b96491a8fc2ac2d6bd5224a86a..19776662c681432469df7ae5382060593efdd997 100644 (file)
@@ -43,7 +43,7 @@ BEGIN {
                      server_branch server_ref
                       stat_exists link_ltarget
                      hashfile
-                      fail ensuredir executable_on_path
+                      fail ensuredir must_getcwd executable_on_path
                       waitstatusmsg failedcmd_waitstatus
                      failedcmd_report_cmd failedcmd
                       runcmd cmdoutput cmdoutput_errok
@@ -58,8 +58,8 @@ BEGIN {
                       $debugprefix *debuglevel *DEBUG
                       shellquote printcmd messagequote
                       $negate_harmful_gitattrs
-                     git_slurp_config_src
-                      workarea_setup);
+                     changedir git_slurp_config_src
+                     playtree_setup);
     # implicitly uses $main::us
     %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO NOCOMMITCHECK)] );
     @EXPORT_OK   = @{ $EXPORT_TAGS{policyflags} };
@@ -222,6 +222,12 @@ sub ensuredir ($) {
     die "mkdir $dir: $!";
 }
 
+sub must_getcwd () {
+    my $d = getcwd();
+    defined $d or fail "getcwd failed: $!";
+    return $d;
+}
+
 sub executable_on_path ($) {
     my ($program) = @_;
     return 1 if $program =~ m{/};
@@ -418,6 +424,12 @@ sub is_fast_fwd ($$) {
     }
 }
 
+sub changedir ($) {
+    my ($newdir) = @_;
+    printdebug "CD $newdir\n";
+    chdir $newdir or confess "chdir: $newdir: $!";
+}
+
 sub git_slurp_config_src ($) {
     my ($src) = @_;
     # returns $r such that $r->{KEY}[] = VALUE
@@ -442,8 +454,8 @@ sub git_slurp_config_src ($) {
     return $r;
 }
 
-sub workarea_setup ($) {
-    # for use in the workarea
+sub playtree_setup ($) {
+    # for use in the playtree
     my ($t_local_git_cfg) = @_;
     # should be run in a directory .git/FOO/BAR of a working tree
     runcmd qw(git init -q);
@@ -464,4 +476,6 @@ sub workarea_setup ($) {
     close GA or die $!;
 }
 
+our $local_git_cfg;
+
 1;