]> Sergey Matveev's repositories - public-inbox.git/commitdiff
import: convert init.defaultBranch to fully qualified ref
authorKyle Meyer <kyle@kyleam.com>
Wed, 7 Apr 2021 23:05:24 +0000 (19:05 -0400)
committerEric Wong <e@80x24.org>
Wed, 7 Apr 2021 23:24:04 +0000 (19:24 -0400)
init.defaultBranch expects a branch name, not a fully qualified ref.
git-init prepends "refs/heads/" automatically and unconditionally.

PublicInbox::Import::default_branch, however, incorrectly passes on
the init.defaultBranch value as is, leading to it being used in spots
where a fully qualified ref is required.  For example, with an
init.defaultBranch value of "master", public-inbox-index for a v2
repository would lead to an all.git repository where HEAD's content is
"ref: master" instead of "ref: refs/heads/master".

Prepend "refs/heads/" to the incoming init.defaultBranch value.

Fixes: 7c2f36de2fb49dd7 (import: respect init.defaultBranch)
lib/PublicInbox/Import.pm

index 46f57e27c2b452d13f31cb3a08111620bb1308a8..3adf9dec21785ee9865a22bcdd8e7a338051dcac 100644 (file)
@@ -25,7 +25,7 @@ sub default_branch () {
                                 { GIT_CONFIG => undef });
                chomp(my $h = <$r> // '');
                close $r;
-               $h eq '' ? 'refs/heads/master' : $h;
+               $h eq '' ? 'refs/heads/master' : "refs/heads/$h";
        }
 }