unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: Rob Herring <robh@kernel.org>
Cc: meta@public-inbox.org
Subject: [PATCH] import: fix handling of init.defaultBranch
Date: Sun, 10 Mar 2024 21:41:30 +0000	[thread overview]
Message-ID: <20240310214130.M631746@dcvr> (raw)
In-Reply-To: <20240310211558.M627956@dcvr>

Eric Wong <e@80x24.org> wrote:
> Will try to fix ASAP but offline problems persist :<

Fortunately it turned out to be a simple fix :x

-------8<-------
Subject: [PATCH] import: fix handling of init.defaultBranch

We must chomp the newline in the branch name if it's set.

Reported-by: Rob Herring <robh@kernel.org>
Link: https://public-inbox.org/meta/CAL_JsqK7P4gjLPyvzxNEcYmxT4j6Ah5f3Pz1RqDHxmysTg3aEg@mail.gmail.com/
Fixes: 73830410e4336b77 (treewide: use run_qx where appropriate, 2023-10-27)
---
 lib/PublicInbox/Import.pm | 1 +
 t/clone-coderepo.t        | 8 +++++---
 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" });

      reply	other threads:[~2024-03-10 21:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06 15:44 crash on git-fast-import Rob Herring
2024-03-08  3:20 ` Eric Wong
2024-03-08 14:38   ` Rob Herring
2024-03-10 21:15     ` Eric Wong
2024-03-10 21:41       ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240310214130.M631746@dcvr \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).