chiark / gitweb /
playground refactoring: Dgit.pm: Expose $local_git_cfg
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 2 Aug 2017 14:09:12 +0000 (15:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 3 Aug 2017 08:56:55 +0000 (09:56 +0100)
This is now the default for playtree_setup.  The caller can simply set
it explicitly.

We make this part of a new :playground export tag for Dgit.pm,
which is going to gain other bits shortly.

And, we add some comments, and move the global; more code and
commentary will appear around this.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Debian/Dgit.pm

index 19776662c681432469df7ae5382060593efdd997..515a32f600b805634a8b3991e21b702c603dc56d 100644 (file)
@@ -61,8 +61,10 @@ BEGIN {
                      changedir git_slurp_config_src
                      playtree_setup);
     # implicitly uses $main::us
-    %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO NOCOMMITCHECK)] );
-    @EXPORT_OK   = @{ $EXPORT_TAGS{policyflags} };
+    %EXPORT_TAGS = ( policyflags => [qw(NOFFCHECK FRESHREPO NOCOMMITCHECK)],
+                    playground => [qw($local_git_cfg)]);
+    @EXPORT_OK   = ( @{ $EXPORT_TAGS{policyflags} },
+                    @{ $EXPORT_TAGS{playground} } );
 }
 
 our @EXPORT_OK;
@@ -454,9 +456,17 @@ sub git_slurp_config_src ($) {
     return $r;
 }
 
-sub playtree_setup ($) {
-    # for use in the playtree
+# ========== playground handling ==========
+
+#   $local_git_cfg    hash of arrays of values: git config from $maindir
+
+our $local_git_cfg;
+
+# ----- playtrees -----
+
+sub playtree_setup (;$) {
     my ($t_local_git_cfg) = @_;
+    $t_local_git_cfg //= $local_git_cfg;
     # should be run in a directory .git/FOO/BAR of a working tree
     runcmd qw(git init -q);
     runcmd qw(git config gc.auto 0);
@@ -476,6 +486,4 @@ sub playtree_setup ($) {
     close GA or die $!;
 }
 
-our $local_git_cfg;
-
 1;