Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 841392 - git-r3.eclass initializes git repo dir without specifying branch specified through EGIT_BRANCH
Summary: git-r3.eclass initializes git repo dir without specifying branch specified th...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-27 22:55 UTC by konsolebox
Modified: 2023-07-18 20:52 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description konsolebox 2022-04-27 22:55:26 UTC
git-r3.eclass: 348: git init --bare || die

It doesn't' specify initial branch even if branch is specified through EGIT_BRANCH.

This makes the default branch warning noise appear when default branch isn't configured through `git config --global init.defaultBranch`.
Comment 1 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-04-28 18:28:46 UTC
Does the actual branch name have any significance?
Comment 2 konsolebox 2022-04-28 18:38:30 UTC
Probably no but at least it initializes to a valid branch and avoid thr noise.
Comment 3 konsolebox 2022-04-28 18:54:36 UTC
If you mean if specifying just any branch name is ok, not sure.  I preferrably wpuld have ${EGIT_BRANCH:-master}.  Globally configured default doesn't really make sense to be applied here since it's about portage.
Comment 4 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-04-28 19:03:06 UTC
(In reply to konsolebox from comment #3)
> If you mean if specifying just any branch name is ok, not sure.  I
> preferrably wpuld have ${EGIT_BRANCH:-master}.  Globally configured default
> doesn't really make sense to be applied here since it's about portage.

yeah, seems like this is the easiest fix.
Comment 5 konsolebox 2022-07-23 07:08:18 UTC
Any decision on this?
Comment 6 konsolebox 2022-12-17 05:28:51 UTC
I examined the git-r3 code again.  I think it's a good idea to initialize a git directory to a more distinguishable name like '__init__'.  This way it would be easier to debug a checkout failure.
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-12-18 19:26:05 UTC
I'm sorry but I'm a little lost here.  What "checkout failure"?  Is there another problem here that I'm not aware of?  I thought this is merely about silencing the warning.

My question was basically whether setting `init.defaultBranch` to an arbitrary value would resolve it, without actually creating any branch.
Comment 8 konsolebox 2022-12-18 19:59:41 UTC
> I'm sorry but I'm a little lost here.  What "checkout failure"?  Is there
> another problem here that I'm not aware of?  I thought this is merely about
> silencing the warning.

The `git init` command needs to be specified with a branch name to silence the noise and a name needs to be chosen. There's no checkout failure but it will be sensible to initialize the branch with a name that isn't "master" so theoretically a "checkout failure" can easily be debugged without needing to see real commits were pulled on a branch with a similar name as the starting branch.

Point is if it's hard to choose an initial branch name for any reason, something like `__init__` will be more ideal than "master" or the one I previously suggested which is ${EGIT_BRANCH:-master}.

> My question was basically whether setting `init.defaultBranch` to an
> arbitrary value would resolve it, without actually creating any branch.

Wouldn't that still create a branch?  Adding `-b` will just explicitly specify the name.

If you mean resolving the warning by specifying the config, yes it can, but the purpose of this issue report is exactly to avoid that step.

Portage needs to be explicit on the initial branch.  It used to always initialize with "master" without the warning, and I'm ok with it being explicitly initialized with "master" too, but it's almost a year now and I'm not sure why getting rid of this warning is being avoided so I thought maybe I should suggest a more practical name that might even just by theory help debugging a bit easier.

Seriously it's quite simple.  Git added a warning for default branches.  Git-r3 used "master" for so long so just initialize branches with the "master" name explicitly.  If "master" isn't a likeable name, pick something maybe slightly more practical like "__init__".
Comment 9 Larry the Git Cow gentoo-dev 2023-07-18 20:52:32 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf52bf96b61db64d46196192407dcb2e0ef67701

commit cf52bf96b61db64d46196192407dcb2e0ef67701
Author:     konsolebox <konsolebox@gmail.com>
AuthorDate: 2022-12-14 11:46:53 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2023-07-18 20:51:53 +0000

    git-r3.eclass: Use '__init__' as initial branch
    
    It silences the default branch warning.
    
    Closes: https://bugs.gentoo.org/841392
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 eclass/git-r3.eclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)