This issue affects the most recent version of cargo pulled from rustup: version 1.45.1 commit f242df6ed. I tried to look through the issues page to see if this has been fixed since, and also the commit history but I didn't see anything to do with this specific issue. If it has already been dealt with I apologize for the unnecessary issue.
In an effort to try and minimize the use of racially insensitive language, as of Git version 2.28.0 there is now the option to set a git config variable (init.defaultBranch) to rename the default branch generated when using git init to something other than "master." Despite this change, using cargo init still generates the git repository using the default branch "master" regardless of the git config variable.
If git init is called and then cargo init is called afterwards, git init will create a git repository with the default branch being defined according to init.defaultBranch, and cargo init will not overwrite that. This ends with the branch being equal to init.defaultBranch as it is intended.
If cargo init is called by itself without a git repository already initialized it will create a git repository with the default branch always being "master." This ends with the branch being "master" which is unintended functionality.
If cargo init is called and then git init is called afterwards, cargo init will create a git repository with the default branch always being "master," and git init will not overwrite that. This ends with the branch being "master" which is unintended functionality (unintended in the sense that as a whole the proper branch name is not used. I expected git init to not overwrite the repository created by cargo init, so this is not a surprise).
To me it seems pretty reasonable that cargo should follow the git config init.defaultBranch variable when creating the git repository for a new project. I know the rust community is actively working on moving away from racially insensitive language as a whole, but obviously that takes time. That being said, this change seems like a fairly minor stepping stone change that would be pretty easy to quickly implement, but would allow people to start new projects off on the right foot.
It might seem kind of stupid because it's really easy to simply switch branches before the initial commit, but because of cargo's ability to quickly and easily spin up projects, it's often that I forget my branch name is not correct despite setting the git config variable.
Needless to say this isn't an urgent change, but it seems like a really easy one to make that would be both a step in the right direction to minimizing racially insensitive language, and fixing cargo so it doesn't violate intended git functionality.
I also just tested on version 1.47.0-nightly (commit aa6872140) and I can confirm the bug still persists.
We do want this to be fixed, but there's only so much we can do.
I believe this is waiting on support in libgit2.
On Tue, Aug 4, 2020, 9:05 PM Will Toll notifications@github.com wrote:
I also just tested on version 1.47.0-nightly (commit aa68721
https://github.com/rust-lang/cargo/commit/aa6872140ab0fa10f641ab0b981d5330d419e927)
and I can confirm the bug still persists.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/rust-lang/cargo/issues/8588#issuecomment-668910891,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AA4JUQBAAYP2VCWSKHF7E7TR7CV7FANCNFSM4PU563KA
.
Yea, this is blocked on https://github.com/libgit2/libgit2/pull/5581.
I though cargo just runs git init in the root folder.
It does not - it uses libgit2 which is not the same thing as git-the-cli-program.
https://github.com/libgit2/libgit2/pull/5581 was merged, so this is fixed, right?
Not yet, but once rust-lang/git2-rs#627 is merged and released, and the dependency is updated here, it should be fixed :)
Most helpful comment
It does not - it uses libgit2 which is not the same thing as git-the-cli-program.