From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B684D1F44D; Sun, 10 Mar 2024 21:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1710106890; bh=ZHVzHOdBWVnhG2oKh9IViMFNQAvsx2bji9eSZQGE/Fc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=J7AsWhXahBoZxRQjYtm6iyuCx6TjM4wGulYvwnWsiYzIrk5iuPzEBsHB5+E7oeR9u 5M1zXB5UGLw57zWJ/mTDNn/EYvEbfeL6UbrWzD2W21uwmTl7CIgTtFVVp0O2rY0AKw R8qMXYBxaLfJVFtUz/2fKvdwenEo7L3FPfzsB5CI= Date: Sun, 10 Mar 2024 21:41:30 +0000 From: Eric Wong To: Rob Herring Cc: meta@public-inbox.org Subject: [PATCH] import: fix handling of init.defaultBranch Message-ID: <20240310214130.M631746@dcvr> References: <20240308032042.M181403@dcvr> <20240310211558.M627956@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240310211558.M627956@dcvr> List-Id: Eric Wong 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 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" });