user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: meta@public-inbox.org
Subject: [PATCH] import: convert init.defaultBranch to fully qualified ref
Date: Wed, 07 Apr 2021 19:05:24 -0400	[thread overview]
Message-ID: <87ft01puff.fsf@kyleam.com> (raw)

Recently I've tried lei on another machine and scratched my head for a
bit about why the local storage seemed to be in a corrupt state.  With
`lei q', no mail was getting imported, and I saw a good number of
"fatal: not a git repository: ..." messages.

It turns out that HEAD's content is invalid, and that's happening
because PublicInbox::Import mishandles init.defaultBranch, which I've
configured on that machine to suppress the associated `git init' hint.

-- >8 --
Subject: [PATCH] import: convert init.defaultBranch to fully qualified ref

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 46f57e27..3adf9dec 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -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";
 	}
 }
 

base-commit: 86c2ebf085cc9897bafcb95b82890f2645f515e5
-- 
2.31.1


             reply	other threads:[~2021-04-07 23:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 23:05 Kyle Meyer [this message]
2021-04-07 23:27 ` [PATCH] import: convert init.defaultBranch to fully qualified ref Eric Wong

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=87ft01puff.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=meta@public-inbox.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).