Message ID | f853fa946f5840518577584a5b8c51660da06928.1605221040.git.gitgitgadget@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Use main as default branch name | expand |
On Thu, Nov 12 2020, Don Goodman-Wilson via GitGitGadget wrote: > The current default name for the initial branch is a loaded term, and > many Open Source projects renamed their principal branches already. A > common choice appears to be `main`. > > Let's follow their lead and change the default of `init.defaultBranch`. I think it makes sense to split this change off from a 28-series test cleanup series. > diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh > index bd3fa3c6da..1b0abcb0f8 100644 > --- a/t/lib-submodule-update.sh > +++ b/t/lib-submodule-update.sh > @@ -144,7 +144,7 @@ create_lib_submodule_repo () { > git checkout -b valid_sub1 && > git revert HEAD && > > - git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" > + git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-main}" Earlier in that function we're doing a "git init". With all this test cleanup I wonder why not just "git rev-parse --abbrev-ref" to get the default name, instead of carrying the hardcoding forward.
Hi Ævar, On Fri, 13 Nov 2020, Ævar Arnfjörð Bjarmason wrote: > > On Thu, Nov 12 2020, Don Goodman-Wilson via GitGitGadget wrote: > > > The current default name for the initial branch is a loaded term, and > > many Open Source projects renamed their principal branches already. A > > common choice appears to be `main`. > > > > Let's follow their lead and change the default of `init.defaultBranch`. > > I think it makes sense to split this change off from a 28-series test > cleanup series. It is not a test cleanup. It is a series of 27 patches preparing the test suite for the change made in the 28th patch. I don't think that it is a good idea to split off that 28th patch from the patches whose entire purpose is to prepare for that 28th patch. > > > diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh > > index bd3fa3c6da..1b0abcb0f8 100644 > > --- a/t/lib-submodule-update.sh > > +++ b/t/lib-submodule-update.sh > > @@ -144,7 +144,7 @@ create_lib_submodule_repo () { > > git checkout -b valid_sub1 && > > git revert HEAD && > > > > - git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" > > + git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-main}" > > Earlier in that function we're doing a "git init". With all this test > cleanup I wonder why not just "git rev-parse --abbrev-ref" to get the > default name, instead of carrying the hardcoding forward. My goal was to keep everything as close to its original as possible. In v2.29.2, this line reads: git checkout master See https://github.com/git/git/blob/v2.29.2/t/lib-submodule-update.sh#L147 to convince yourself. Personally, I would have used something like main=$(git symbolic-ref --short HEAD) && [...] git checkout $main instead of what you suggested. That's a topic for another patch (series), though. Ciao, Dscho
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > Hi Ævar, > > On Fri, 13 Nov 2020, Ævar Arnfjörð Bjarmason wrote: > >> >> On Thu, Nov 12 2020, Don Goodman-Wilson via GitGitGadget wrote: >> >> > The current default name for the initial branch is a loaded term, and >> > many Open Source projects renamed their principal branches already. A >> > common choice appears to be `main`. >> > >> > Let's follow their lead and change the default of `init.defaultBranch`. >> >> I think it makes sense to split this change off from a 28-series test >> cleanup series. > > It is not a test cleanup. It is a series of 27 patches preparing the test > suite for the change made in the 28th patch. > > I don't think that it is a good idea to split off that 28th patch from > the patches whose entire purpose is to prepare for that 28th patch. Well, I personally think that the "purpose" of the first 27 patches must be updated if that is the case. The test should NOT be prepared only to work in the post "switch from master to main" world. Instead, what we want to see is that the test would work whether the fallback default value for init.defaultBranch is 'master' (i.e. old world) or 'main (i.e. a possible new world). Perhaps by using the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME mechanism for tests that relies on a particular value to be the fallback default. So in the sense, the goal the first 26 patches support is the 27th one, which is the most important one in the series from _my_ point of view. We get ourselves prepared so that 28th one can happen at any time. That way, as long as the first 27 patches land, we will keep the same test coverage as we've always had, regardless of the timing we actually ship the 28th one to the production environment. > Personally, I would have used something like > > main=$(git symbolic-ref --short HEAD) && > [...] > git checkout $main > > instead of what you suggested. That's a topic for another patch (series), > though. Yeah, I would have used $primary or some word that is neither these m* names, but I think that is a good alternative, when workable, to the GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME mechanism. When the golden master compared with actual output hardcodes the expected branch names, however, the approach becomes awkward, though. Thanks.
diff --git a/refs.c b/refs.c index 392f0bbf68..5576a90573 100644 --- a/refs.c +++ b/refs.c @@ -575,7 +575,7 @@ char *repo_default_branch_name(struct repository *r) die(_("could not retrieve `%s`"), config_display_key); if (!ret) - ret = xstrdup("master"); + ret = xstrdup("main"); full_ref = xstrfmt("refs/heads/%s", ret); if (check_refname_format(full_ref, 0)) diff --git a/t/lib-submodule-update.sh b/t/lib-submodule-update.sh index bd3fa3c6da..1b0abcb0f8 100644 --- a/t/lib-submodule-update.sh +++ b/t/lib-submodule-update.sh @@ -144,7 +144,7 @@ create_lib_submodule_repo () { git checkout -b valid_sub1 && git revert HEAD && - git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-master}" + git checkout "${GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME-main}" ) }