git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Phillip Wood <phillip.wood123@gmail.com>
Cc: git@vger.kernel.org,
	 Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Wing Huang <huangsen365@gmail.com>
Subject: Re: [PATCH 6/6] breaking-changes: switch default branch to main
Date: Wed, 27 Aug 2025 11:41:01 -0700	[thread overview]
Message-ID: <xmqqplcgzjya.fsf@gitster.g> (raw)
In-Reply-To: <487d1a33130cb2fafadcf98da00a332a7408a0e8.1756308283.git.phillip.wood@dunelm.org.uk> (Phillip Wood's message of "Wed, 27 Aug 2025 16:24:50 +0100")

Phillip Wood <phillip.wood123@gmail.com> writes:

> diff --git a/Documentation/BreakingChanges.adoc b/Documentation/BreakingChanges.adoc
> index f8d2eba061c..93922299321 100644
> --- a/Documentation/BreakingChanges.adoc
> +++ b/Documentation/BreakingChanges.adoc
> @@ -165,6 +165,11 @@ A prerequisite for this change is that the ecosystem is ready to support the
>  "reftable" format. Most importantly, alternative implementations of Git like
>  JGit, libgit2 and Gitoxide need to support it.
>  
> +* The default branch name will be `main`. We have been warning that the default
> +  name will change since 675704c74dd (init: provide useful advice about
> +  init.defaultBranch, 2020-12-11). The new name matches the default branch name
> +  used by many of the big git forges.
> +

Good.

> diff --git a/Documentation/git-init.adoc b/Documentation/git-init.adoc
> index a0dffba665f..39d4db6bccb 100644
> --- a/Documentation/git-init.adoc
> +++ b/Documentation/git-init.adoc
> @@ -77,9 +77,15 @@ If this is a reinitialization, the repository will be moved to the specified pat
>  `-b <branch-name>`::
>  `--initial-branch=<branch-name>`::
>  Use _<branch-name>_ for the initial branch in the newly created
> -repository.  If not specified, fall back to the default name (currently
> -`master`, but this is subject to change in the future; the name can be
> -customized via the `init.defaultBranch` configuration variable).
> +repository.  If not specified, fall back to the default name
> +ifndef::with-breaking-changes[]
> +(currently `master`, but this will change to `main` when Git 3.0 is released).
> +endif::with-breaking-changes[]
> +ifdef::with-breaking-changes[]
> +(`main`).
> +endif::with-breaking-changes[]

Good.  We might have to change it back to "(currently `main`)" again
but I do not see the need to prepare for such a re-rename.  As we do
not have the "currently", we can say

	... to the default name `main`.

without parentheses.

> +The default name can be customized via the `init.defaultBranch` configuration
> +variable.

> diff --git a/advice.c b/advice.c
> index e5f0ff84491..48c49ee4145 100644
> --- a/advice.c
> +++ b/advice.c
> @@ -51,7 +51,9 @@ static struct {
>  	[ADVICE_AM_WORK_DIR] 				= { "amWorkDir" },
>  	[ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME] 	= { "checkoutAmbiguousRemoteBranchName" },
>  	[ADVICE_COMMIT_BEFORE_MERGE]			= { "commitBeforeMerge" },
> +#ifndef WITH_BREAKING_CHANGES
>  	[ADVICE_DEFAULT_BRANCH_NAME]			= { "defaultBranchName" },
> +#endif /* WITH_BREAKING_CHANGES */
>  	[ADVICE_DETACHED_HEAD]				= { "detachedHead" },
>  	[ADVICE_DIVERGING]				= { "diverging" },
>  	[ADVICE_FETCH_SET_HEAD_WARN]			= { "fetchRemoteHEADWarn" },
> diff --git a/advice.h b/advice.h
> index 727dcecf4a3..fc1dc872049 100644
> --- a/advice.h
> +++ b/advice.h
> @@ -18,7 +18,9 @@ enum advice_type {
>  	ADVICE_AM_WORK_DIR,
>  	ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME,
>  	ADVICE_COMMIT_BEFORE_MERGE,
> +#ifndef WITH_BREAKING_CHANGES
>  	ADVICE_DEFAULT_BRANCH_NAME,
> +#endif /* WITH_BREAKING_CHANGES */
>  	ADVICE_DETACHED_HEAD,
>  	ADVICE_DIVERGING,
>  	ADVICE_FETCH_SET_HEAD_WARN,

Good.

> diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
> index 01823fd0f14..a21834043f3 100755
> --- a/ci/run-build-and-tests.sh
> +++ b/ci/run-build-and-tests.sh
> @@ -9,7 +9,6 @@ run_tests=t
>  
>  case "$jobname" in
>  linux-breaking-changes)
> -	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main

Questionable.

> diff --git a/refs.c b/refs.c
> index 4ff55cf24f6..e73f63ff6b8 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -627,10 +627,12 @@ void expand_ref_prefix(struct strvec *prefixes, const char *prefix)
>  		strvec_pushf(prefixes, *p, len, prefix);
>  }
>  
> +#ifndef WITH_BREAKING_CHANGES
>  static const char default_branch_name_advice[] = N_(
>  "Using '%s' as the name for the initial branch. This default branch name\n"
> -"is subject to change. To configure the initial branch name to use in all\n"
> -"of your new repositories, which will suppress this warning, call:\n"
> +"will change to \"main\" in Git 3.0. To configure the initial branch name\n"
> +"to use in all of your new repositories, which will suppress this warning,\n"
> +"call:\n"
>  "\n"
>  "\tgit config --global init.defaultBranch <name>\n"
>  "\n"
> @@ -639,24 +641,32 @@ static const char default_branch_name_advice[] = N_(
>  "\n"
>  "\tgit branch -m <name>\n"
>  );
> +#endif /* WITH_BREAKING_CHANGES */

Good.

>  char *repo_default_branch_name(struct repository *r, int quiet)
>  {
>  	const char *config_key = "init.defaultbranch";
>  	const char *config_display_key = "init.defaultBranch";
>  	char *ret = NULL, *full_ref;
> +#ifndef WITH_BREAKING_CHANGES
>  	const char *env = getenv("GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME");
>  
>  	if (env && *env)
>  		ret = xstrdup(env);
> -	else if (repo_config_get_string(r, config_key, &ret) < 0)
> +#endif /* WITH_BREAKING_CHANGES */

Questionable.

> +	if (!ret && repo_config_get_string(r, config_key, &ret) < 0)
>  		die(_("could not retrieve `%s`"), config_display_key);
>  
>  	if (!ret) {
> +#ifdef WITH_BREAKING_CHANGES
> +		ret = xstrdup("main");
> +		(void) quiet; /* Silence -Wunused-parameter */
> +#else
>  		ret = xstrdup("master");
>  		if (!quiet)
>  			advise_if_enabled(ADVICE_DEFAULT_BRANCH_NAME,
>  					  _(default_branch_name_advice), ret);
> +#endif /* WITH_BREAKING_CHANGES */

Very good.

Thanks.

  reply	other threads:[~2025-08-27 18:41 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-27 15:24 [PATCH 0/6] breaking changes: switch default initial branch name to "main" Phillip Wood
2025-08-27 15:24 ` [PATCH 1/6] t0018: switch default branch name to main Phillip Wood
2025-08-27 17:21   ` Junio C Hamano
2025-08-28 14:00     ` Phillip Wood
2025-08-28 16:49       ` Junio C Hamano
2025-08-28 21:31         ` brian m. carlson
2025-08-27 15:24 ` [PATCH 2/6] t4013: " Phillip Wood
2025-08-27 15:24 ` [PATCH 3/6] t9902: " Phillip Wood
2025-08-27 15:24 ` [PATCH 4/6] t0613: stop setting default initial branch Phillip Wood
2025-08-27 17:30   ` Junio C Hamano
2025-08-27 15:24 ` [PATCH 5/6] t1403: remove dependency on GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME Phillip Wood
2025-08-27 15:24 ` [PATCH 6/6] breaking-changes: switch default branch to main Phillip Wood
2025-08-27 18:41   ` Junio C Hamano [this message]
2025-09-02 11:36   ` Patrick Steinhardt
2025-09-02 15:13     ` Phillip Wood
2025-09-03  4:44       ` Patrick Steinhardt
2025-09-03  9:54         ` Phillip Wood
2025-09-03 11:51           ` Patrick Steinhardt
2025-09-03 18:40           ` Junio C Hamano
2025-09-04  7:09             ` Patrick Steinhardt
2025-09-04 13:30               ` Phillip Wood
2025-09-05  6:07                 ` Patrick Steinhardt
2025-09-04 13:27             ` Phillip Wood
2025-08-28 13:12 ` [PATCH 0/6] breaking changes: switch default initial branch name to "main" Johannes Schindelin
2025-09-04 13:21 ` [PATCH v2 0/4] " Phillip Wood
2025-09-04 13:21   ` [PATCH v2 1/4] breaking-changes: switch default branch to main Phillip Wood
2025-09-04 17:40     ` Junio C Hamano
2025-09-05 10:06       ` Phillip Wood
2025-09-05 15:04         ` Junio C Hamano
2025-09-04 13:21   ` [PATCH v2 2/4] t4013: switch default branch name " Phillip Wood
2025-09-04 13:21   ` [PATCH v2 3/4] t9902: " Phillip Wood
2025-09-04 18:27     ` Junio C Hamano
2025-09-05 10:07       ` Phillip Wood
2025-09-05 12:14     ` Patrick Steinhardt
2025-09-09  9:12       ` Phillip Wood
2025-09-04 13:21   ` [PATCH v2 4/4] t0613: stop setting default initial branch Phillip Wood
2025-09-04 18:35     ` Junio C Hamano
2025-09-05 10:09       ` Phillip Wood
2025-09-04 17:03   ` [PATCH v2 0/4] breaking changes: switch default initial branch name to "main" Junio C Hamano
2025-09-04 18:47     ` Phillip Wood
2025-09-10 15:28 ` [PATCH v3 " Phillip Wood
2025-09-10 15:29   ` [PATCH v3 1/4] breaking-changes: switch default branch to main Phillip Wood
2025-09-10 15:29   ` [PATCH v3 2/4] t4013: switch default branch name " Phillip Wood
2025-09-10 15:29   ` [PATCH v3 3/4] t9902: " Phillip Wood
2025-09-10 15:29   ` [PATCH v3 4/4] t0613: stop setting default initial branch Phillip Wood
2025-09-10 20:41   ` [PATCH v3 0/4] breaking changes: switch default initial branch name to "main" Junio C Hamano
2025-09-17  9:22     ` Junio C Hamano
2025-09-17 12:02       ` Kristoffer Haugsbakk
2025-09-17 15:02         ` Junio C Hamano
2025-09-17 14:53       ` Phillip Wood
2025-09-17 15:21         ` Junio C Hamano
2025-09-17 16:16           ` Junio C Hamano
2025-09-18 15:06             ` Phillip Wood
2025-09-17 16:18   ` [PATCH v2 5/4] initial branch: give hints after switching the default name Junio C Hamano
2025-09-18 15:06     ` Phillip Wood
2025-09-18 18:42       ` Junio C Hamano

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqplcgzjya.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=huangsen365@gmail.com \
    --cc=phillip.wood123@gmail.com \
    /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.
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 NNTP newsgroup(s).