about summary refs log tree commit homepage
diff options
context:
space:
mode:
-rw-r--r--lib/PublicInbox/Import.pm1
-rw-r--r--t/clone-coderepo.t8
2 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index a951874b..ed34d548 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -26,6 +26,7 @@ sub default_branch () {
         state $default_branch = do {
                 my $h = run_qx([qw(git config --global init.defaultBranch)],
                                  { GIT_CONFIG => undef });
+                chomp $h;
                 $h eq '' ? 'refs/heads/master' : "refs/heads/$h";
         }
 }
diff --git a/t/clone-coderepo.t b/t/clone-coderepo.t
index c0951941..c6180fc4 100644
--- a/t/clone-coderepo.t
+++ b/t/clone-coderepo.t
@@ -7,6 +7,7 @@ use PublicInbox::Import;
 use File::Temp;
 use File::Path qw(remove_tree);
 use PublicInbox::SHA qw(sha1_hex);
+use PublicInbox::IO;
 require_mods(qw(json Plack::Builder HTTP::Date HTTP::Status));
 require_git_http_backend;
 require_git '1.8.5';
@@ -38,9 +39,10 @@ my $t0 = time - 1;
 my $m; # manifest hashref
 
 {
-        my $rdr = {};
-        my $fi_data = './t/git.fast-import-data';
-        open $rdr->{0}, '<', $fi_data or xbail "open($fi_data): $!";
+        my $fi_data = PublicInbox::IO::try_cat './t/git.fast-import-data';
+        my $db = PublicInbox::Import::default_branch;
+        $fi_data =~ s!\brefs/heads/master\b!$db!gs;
+        my $rdr = { 0 => \$fi_data };
         my @git = ('git', "--git-dir=$pa");
         xsys_e([@git, qw(fast-import --quiet)], undef, $rdr);
         xsys_e([qw(/bin/cp -Rp a.git b.git)], undef, { -C => "$tmpdir/src" });