threads / patch / 62625

patch, 5 partsremote: announce removal of "branches/" and "remotes/"

Subject: [PATCH 0/5] remote: announce removal of "branches/" and "remotes/"

## tl;dr

47 messages between Dec 11, 2024 and Feb 26, 2025. Diffs are folded; open one to read it.

replies: 46people: 7as markdown or json

Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · lore
Hi,

back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). This mechanism was replaced later that year with the "remotes/" directory. These mechanism have evenutally been replaced by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes. Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011.

This patch series follows through with the deprecation of these and announces them for removal in Git 3.0. Furthermore, it creates the infra to compile Git with such breaking changes enabled and wires up a CI job both for GitHub and GitLab to test those breaking changes.

The series is based on top caacdb5dfd (The fifteenth batch, 2024-12-10) with ps/build at 904339edbd (Introduce support for the Meson build system, 2024-12-06) merged into it.

Thanks!
Patrick
---
Patrick Steinhardt (5):
      Makefile: wire up build option for deprecated features
      ci: merge linux-gcc-default into linux-gcc
      ci: repurpose "linux-gcc" job for deprecations
      builtin/pack-redundant: remove subcommand with breaking changes
      remote: announce removal of "branches/" and "remotes/"
 .github/workflows/main.yml             |  6 +----
 .gitlab-ci.yml                         |  6 +----
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 GIT-BUILD-OPTIONS.in                   |  1 +
 Makefile                               |  7 +++++
 builtin/remote.c                       |  2 ++
 ci/lib.sh                              |  5 ----
 ci/run-build-and-tests.sh              |  3 ++-
 contrib/buildsystems/CMakeLists.txt    |  1 +
 git.c                                  |  2 ++
 meson.build                            |  6 +++++
 meson_options.txt                      |  2 ++
 remote.c                               |  6 +++++
 remote.h                               |  2 ++
 t/t5323-pack-redundant.sh              |  6 +++++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 t/test-lib.sh                          |  4 +++
 21 files changed, 112 insertions(+), 59 deletions(-)

--- base-commit: 713ec79a9091cec60b110d605b418904759982ab change-id: 20241205-pks-remote-branches-deprecation-037a4389a377

Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · re: Patrick Steinhardt · lore

[PATCH 1/5] Makefile: wire up build option for deprecated features

With 57ec9254eb (docs: introduce document to announce breaking changes, 2024-06-14), we have introduced a new document that tracks upcoming breaking changes in the Git project. In 2454970930 (BreakingChanges: early adopter option, 2024-10-11) we have amended the document a bit to mention that any introduced breaking changes must be accompanied by logic that allows us to easily enable the breaking change at runtime. While we already have two breaking changes lined up, neither of them has such a switch because they predate those instructions.

Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and wire it up with both our Makefiles and Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 GIT-BUILD-OPTIONS.in                | 1 +
 Makefile                            | 5 +++++
 contrib/buildsystems/CMakeLists.txt | 1 +
 meson.build                         | 6 ++++++
 meson_options.txt                   | 2 ++
 t/test-lib.sh                       | 4 ++++
 6 files changed, 19 insertions(+)
Show changes to 6 files +19 −0

GIT-BUILD-OPTIONS.in, Makefile, contrib/buildsystems/CMakeLists.txt, meson.build, meson_options.txt, t/test-lib.sh

diff --git a/GIT-BUILD-OPTIONS.in b/GIT-BUILD-OPTIONS.in
index f651116102ae2977622dccd12b199fe7ad65af99..f1d0ecf123031dd13232cc63e100da528bfea16a 100644
--- a/GIT-BUILD-OPTIONS.in
+++ b/GIT-BUILD-OPTIONS.in
@@ -45,3 +45,4 @@ GITWEBDIR=@GITWEBDIR@
 USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
 LOCALEDIR=@LOCALEDIR@
 BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
+WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@
diff --git a/Makefile b/Makefile
index 06f01149ecf399ae4bb1932188a007948d767283..dc3c980aa7a4f42d27ed72415a636ac82b2a5684 100644
--- a/Makefile
+++ b/Makefile
@@ -2230,6 +2230,10 @@ ifdef FSMONITOR_OS_SETTINGS
 	COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
 endif
 
+ifdef WITH_BREAKING_CHANGES
+	BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
@@ -3187,6 +3191,7 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
 		-e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
 		-e "s!@BROKEN_PATH_FIX@!\'$(BROKEN_PATH_FIX)\'!" \
+		-e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 49904ca8a93981c514540bad5efa6833ddd14426..63d008892848c20d5937d9a624a480f700b19498 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
 string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
 string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
 string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
+string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
diff --git a/meson.build b/meson.build
index 0dccebcdf16b07650d943e53643f0e09e2975cc9..316cd9326437876828a88d96a1bc93d503199900 100644
--- a/meson.build
+++ b/meson.build
@@ -644,6 +644,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
 build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
 build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
 
+if get_option('breaking_changes')
+  build_options_config.set('WITH_BREAKING_CHANGES', 'YesPlease')
+else
+  build_options_config.set('WITH_BREAKING_CHANGES', '')
+endif
+
 if get_option('sane_tool_path') != ''
   build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
 else
diff --git a/meson_options.txt b/meson_options.txt
index 32a72139bae870745d9131cc9086a4594826be91..800e518d959c4143812f8840415b99a593667a8d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -43,6 +43,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
   description: 'The backend used for hashing objects with the SHA256 object format')
 
 # Build tweaks.
+option('breaking_changes', type: 'boolean', value: false,
+  description: 'Enable upcoming breaking changes.')
 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
   description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62dfcc4aaf959d0cf066d07663d939e14f92485c..6e423f655d35adf5a2d4f8b3a78d9e8c1119caab 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
 	curl --version
 '
 
+test_lazy_prereq WITHOUT_BREAKING_CHANGES '
+	test -z "$WITH_BREAKING_CHANGES"
+'
+
 # SHA1 is a test if the hash algorithm in use is SHA-1.  This is both for tests
 # which will not work with other hash algorithms and tests that work but don't
 # test anything meaningful (e.g. special values which cause short collisions).
-- 
2.47.1.447.ga7e8429e30.dirty
Kristoffer Haugsbakk· Dec 11, 2024, 13:06 UTC · re: Patrick Steinhardt · lore

Re: [PATCH 1/5] Makefile: wire up build option for deprecated features

On Wed, Dec 11, 2024, at 11:56, Patrick Steinhardt wrote:
> logic that allows us to easily enable the breaking change at runtime.
s/at runtime/at compile-time/
Show 7 quoted lines
> While we already have two breaking changes lined up, neither of them has
> such a switch because they predate those instructions.
>
> Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and
> wire it up with both our Makefiles and Meson.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
Patrick Steinhardt· Dec 13, 2024, 05:26 UTC · re: Kristoffer Haugsbakk · lore

Re: [PATCH 1/5] Makefile: wire up build option for deprecated features

On Wed, Dec 11, 2024 at 02:06:42PM +0100, Kristoffer Haugsbakk wrote:
> On Wed, Dec 11, 2024, at 11:56, Patrick Steinhardt wrote:
> > logic that allows us to easily enable the breaking change at runtime.
> 
> s/at runtime/at compile-time/
Good catch, thanks!
Patrick
Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · re: Patrick Steinhardt · lore

[PATCH 2/5] ci: merge linux-gcc-default into linux-gcc

The "linux-gcc-default" job is mostly doing the same as the "linux-gcc" job, except for a couple of minor differences:

  - We use an explicit GCC version instead of the default version
    provided by the distribution. We have other jobs that test with
    "gcc-8", making this distinction pointless.
  - We don't set up the Python version explicitly, and instead use the
    default Python version. Python 2 has been end-of-life for quite a
    while now though, making this distinction less interesting.
  - We set up the default branch name to be "main" in "linux-gcc". We
    have other testcases that don't and also some that explicitly use
    "master".

So overall, the job does not add much to our test coverage. Merge it into our "linux-gcc" job to reduce our test matrix a bit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 4 ----
 .gitlab-ci.yml             | 4 ----
 ci/lib.sh                  | 5 -----
 3 files changed, 13 deletions(-)
Show changes to 3 files +0 −13

.github/workflows/main.yml, .gitlab-ci.yml, ci/lib.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 808ddc19b8a799abc414c6d6ba078a6e5be6bdfb..32d35d2257812f02121b20c3cae342d626481553 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -271,7 +271,6 @@ jobs:
             pool: ubuntu-latest
           - jobname: linux-gcc
             cc: gcc
-            cc_package: gcc-8
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
             cc: gcc
@@ -286,9 +285,6 @@ jobs:
           - jobname: osx-gcc
             cc: gcc-13
             pool: macos-13
-          - jobname: linux-gcc-default
-            cc: gcc
-            pool: ubuntu-latest
           - jobname: linux-leaks
             cc: gcc
             pool: ubuntu-latest
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a1bc92893f27d6dd404133686b71c8061e55618c..b86bb0bdb3363e06e6fe4195c34babd67cf7e8cc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,14 +46,10 @@ test:linux:
       - jobname: linux-gcc
         image: ubuntu:20.04
         CC: gcc
-        CC_PACKAGE: gcc-8
       - jobname: linux-TEST-vars
         image: ubuntu:20.04
         CC: gcc
         CC_PACKAGE: gcc-8
-      - jobname: linux-gcc-default
-        image: ubuntu:latest
-        CC: gcc
       - jobname: linux-leaks
         image: ubuntu:latest
         CC: gcc
diff --git a/ci/lib.sh b/ci/lib.sh
index 930f98d7228166c37c236beb062b14675fb68ef3..e67c481d4fe08d0ebc3253a7a832a96f65c79ffe 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -328,11 +328,6 @@ export SKIP_DASHED_BUILT_INS=YesPlease
 
 case "$distro" in
 ubuntu-*)
-	if test "$jobname" = "linux-gcc-default"
-	then
-		break
-	fi
-
 	# Python 2 is end of life, and Ubuntu 23.04 and newer don't actually
 	# have it anymore. We thus only test with Python 2 on older LTS
 	# releases.
-- 
2.47.1.447.ga7e8429e30.dirty
Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · re: Patrick Steinhardt · lore

[PATCH 3/5] ci: repurpose "linux-gcc" job for deprecations

The "linux-gcc" job isn't all that interesting by itself and can be considered more or less the "standard" job: it is running with a reasonably up-to-date image and uses GCC as a compiler, both of which we already cover in other jobs.

There is one exception though: we change the default branch to be "main" instead of "master", so it is forging ahead a bit into the future to make sure that this change does not cause havoc. So let's expand on this a bit and also add the new "WITH_BREAKING_CHANGES" flag to the mix.

Rename the job to "linux-breaking-changes" accordingly.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 2 +-
 .gitlab-ci.yml             | 2 +-
 ci/run-build-and-tests.sh  | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
Show changes to 3 files +4 −3

.github/workflows/main.yml, .gitlab-ci.yml, ci/run-build-and-tests.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 32d35d2257812f02121b20c3cae342d626481553..46b96fb96cc6e2659fe0b4b640f7e671587d059a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -269,7 +269,7 @@ jobs:
           - jobname: linux-reftable
             cc: clang
             pool: ubuntu-latest
-          - jobname: linux-gcc
+          - jobname: linux-breaking-changes
             cc: gcc
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b86bb0bdb3363e06e6fe4195c34babd67cf7e8cc..492e5d9082dbdb3389c173f2b5a45fe43f4bea41 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -43,7 +43,7 @@ test:linux:
       - jobname: linux-reftable
         image: ubuntu:latest
         CC: clang
-      - jobname: linux-gcc
+      - jobname: linux-breaking-changes
         image: ubuntu:20.04
         CC: gcc
       - jobname: linux-TEST-vars
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 2e28d02b20f2469afddc4e04fdbd18465babb1ef..2ccd812fb4e025be3b8e9ab2ec6ae44e92944ab0 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -13,8 +13,9 @@ esac
 run_tests=t
 
 case "$jobname" in
-linux-gcc)
+linux-breaking-changes)
 	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+	export WITH_BREAKING_CHANGES=YesPlease
 	;;
 linux-TEST-vars)
 	export GIT_TEST_SPLIT_INDEX=yes
-- 
2.47.1.447.ga7e8429e30.dirty
Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · re: Patrick Steinhardt · lore

[PATCH 4/5] builtin/pack-redundant: remove subcommand with breaking changes

The git-pack-redundant(1) subcommand has been announced for removal with 53a92c9552 (Documentation/BreakingChanges: announce removal of git-pack-redundant(1), 2024-09-02). Stop compiling the subcommand in case the `WITH_BREAKING_CHANGES` build flag is set.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Makefile                  | 2 ++
 git.c                     | 2 ++
 t/t5323-pack-redundant.sh | 6 ++++++
 3 files changed, 10 insertions(+)
Show changes to 3 files +10 −0

Makefile, git.c, t/t5323-pack-redundant.sh

diff --git a/Makefile b/Makefile
index dc3c980aa7a4f42d27ed72415a636ac82b2a5684..e6b0d859803ac4d53079ec2a39143441a5662203 100644
--- a/Makefile
+++ b/Makefile
@@ -1278,7 +1278,9 @@ BUILTIN_OBJS += builtin/mv.o
 BUILTIN_OBJS += builtin/name-rev.o
 BUILTIN_OBJS += builtin/notes.o
 BUILTIN_OBJS += builtin/pack-objects.o
+ifndef WITH_BREAKING_CHANGES
 BUILTIN_OBJS += builtin/pack-redundant.o
+endif
 BUILTIN_OBJS += builtin/pack-refs.o
 BUILTIN_OBJS += builtin/patch-id.o
 BUILTIN_OBJS += builtin/prune-packed.o
diff --git a/git.c b/git.c
index 46b3c740c5d665388917c6eee3052cc3ef8368f2..a13c32bcdc694460fcafe8079d3aa6e8caea1b4c 100644
--- a/git.c
+++ b/git.c
@@ -589,7 +589,9 @@ static struct cmd_struct commands[] = {
 	{ "name-rev", cmd_name_rev, RUN_SETUP },
 	{ "notes", cmd_notes, RUN_SETUP },
 	{ "pack-objects", cmd_pack_objects, RUN_SETUP },
+#ifndef WITH_BREAKING_CHANGES
 	{ "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT },
+#endif
 	{ "pack-refs", cmd_pack_refs, RUN_SETUP },
 	{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
 	{ "pickaxe", cmd_blame, RUN_SETUP },
diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
index 8dbbcc5e51c06d7c5f56fcb3107860fcb66a5106..688cd9706c876a7edcaf0bcd642ae08ece188d4d 100755
--- a/t/t5323-pack-redundant.sh
+++ b/t/t5323-pack-redundant.sh
@@ -36,6 +36,12 @@ relationship between packs and objects is as follows:
 
 . ./test-lib.sh
 
+if ! test_have_prereq WITHOUT_BREAKING_CHANGES
+then
+	skip_all='skipping git-pack-redundant tests; built with breaking changes'
+	test_done
+fi
+
 main_repo=main.git
 shared_repo=shared.git
 
-- 
2.47.1.447.ga7e8429e30.dirty
Patrick Steinhardt· Dec 11, 2024, 10:56 UTC · re: Patrick Steinhardt · lore

[PATCH 5/5] remote: announce removal of "branches/" and "remotes/"

Back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). This mechanism was replaced later that year with the "remotes/" directory. These mechanism have evenutally been replaced by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes.

Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011. Follow through with the deprecation and finally announce the removal of these features in Git 3.0.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 builtin/remote.c                       |  2 ++
 remote.c                               |  6 +++++
 remote.h                               |  2 ++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 9 files changed, 79 insertions(+), 43 deletions(-)
Show changes to 9 files +79 −43

Documentation/BreakingChanges.txt, Documentation/gitrepository-layout.txt, builtin/remote.c, remote.c, remote.h, t/t5505-remote.sh, t/t5510-fetch.sh, t/t5515-fetch-merge-logic.sh, t/t5516-fetch-push.sh

diff --git a/Documentation/BreakingChanges.txt b/Documentation/BreakingChanges.txt
index 27acff86db4883a7d7967343c61711959b75a473..f9a3bc982efc1deb6570d1911e9f34731c6c2864 100644
--- a/Documentation/BreakingChanges.txt
+++ b/Documentation/BreakingChanges.txt
@@ -154,6 +154,31 @@ Cf. <xmqq1rjuz6n3.fsf_-_@gitster.c.googlers.com>,
     <CAKvOHKAFXQwt4D8yUCCkf_TQL79mYaJ=KAKhtpDNTvHJFuX1NA@mail.gmail.com>,
     <20230323204047.GA9290@coredump.intra.peff.net>,
 
+* Support for storing shorthands for remote URLs in "$GIT_COMMON_DIR/branches/"
+  and "$GIT_COMMON_DIR/remotes/" has been long superseded by storing remotes in
+  the repository configuration.
++
+The mechanism has originally been introduced in f170e4b39d ([PATCH] fetch/pull:
+short-hand notation for remote repositories., 2005-07-16) and was superseded by
+6687f8fea2 ([PATCH] Use .git/remote/origin, not .git/branches/origin.,
+2005-08-20), where we switched from ".git/branches/" to ".git/remotes/". That
+commit already mentions an upcoming deprecation of the ".git/branches/"
+directory, and starting with a1d4aa7424 (Add repository-layout document.,
+2005-09-01) we have also marked this layout as deprecated. Eventually we also
+started to migrate away from ".git/remotes/" in favor of config-based remotes,
+and we have marked the directory as legacy in 3d3d282146 (Documentation:
+Grammar correction, wording fixes and cleanup, 2011-08-23)
++
+As our documentation mentions, these directories are not to be found in modern
+repositories at all and most users aren't even aware of these mechanisms. They
+have been deprecated for almost 20 years and 14 years respectively, and I am
+not aware of any reason why anybody would want to use these mechanisms.
+Furthermore, the ".git/branches/" directory is noadays misleadingly named and
+may cause confusion as "branches" are almost exclusively used in the context of
+references.
++
+These features will be removed.
+
 == Superseded features that will not be deprecated
 
 Some features have gained newer replacements that aim to improve the design in
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index fa8b51daf08775f3d666a910d9b00486627e02af..85911ca8ea0b222ab9cc3dc2dd99c5136c72bd2b 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -153,7 +153,7 @@ config.worktree::
 	linkgit:git-worktree[1]).
 
 branches::
-	A slightly deprecated way to store shorthands to be used
+	A deprecated way to store shorthands to be used
 	to specify a URL to 'git fetch', 'git pull' and 'git push'.
 	A file can be stored as `branches/<name>` and then
 	'name' can be given to these commands in place of
@@ -162,7 +162,8 @@ branches::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/branches" will be used instead.
-
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 hooks::
 	Hooks are customization scripts used by various Git
@@ -238,6 +239,8 @@ remotes::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/remotes" will be used instead.
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 logs::
 	Records of changes made to refs are stored in this directory.
diff --git a/builtin/remote.c b/builtin/remote.c
index 1ad3e70a6b438a3c4446b16c02dc5c23c7fa14be..e565b2b3fec8bf2e4182e85d8d08953a14416881 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -640,10 +640,12 @@ static int migrate_file(struct remote *remote)
 	strbuf_addf(&buf, "remote.%s.fetch", remote->name);
 	for (i = 0; i < remote->fetch.nr; i++)
 		git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (remote->origin == REMOTE_REMOTES)
 		unlink_or_warn(git_path("remotes/%s", remote->name));
 	else if (remote->origin == REMOTE_BRANCHES)
 		unlink_or_warn(git_path("branches/%s", remote->name));
+#endif /* WITH_BREAKING_CHANGES */
 	strbuf_release(&buf);
 
 	return 0;
diff --git a/remote.c b/remote.c
index 10104d11e3cba1908cd35f22b54e167755770404..55e91fab47197313fd8c2c1c5f73fcd46b4df4f7 100644
--- a/remote.c
+++ b/remote.c
@@ -293,6 +293,7 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
 	rewrite->instead_of_nr++;
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static const char *skip_spaces(const char *s)
 {
 	while (isspace(*s))
@@ -374,6 +375,7 @@ static void read_branches_file(struct remote_state *remote_state,
 	strbuf_release(&buf);
 	free(to_free);
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static int handle_config(const char *key, const char *value,
 			 const struct config_context *ctx, void *cb)
@@ -572,6 +574,7 @@ static void read_config(struct repository *repo, int early)
 	alias_all_urls(repo->remote_state);
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static int valid_remote_nick(const char *name)
 {
 	if (!name[0] || is_dot_or_dotdot(name))
@@ -583,6 +586,7 @@ static int valid_remote_nick(const char *name)
 			return 0;
 	return 1;
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static const char *remotes_remote_for_branch(struct remote_state *remote_state,
 					     struct branch *branch,
@@ -725,12 +729,14 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
 				   &name_given);
 
 	ret = make_remote(remote_state, name, 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (valid_remote_nick(name) && have_git_dir()) {
 		if (!valid_remote(ret))
 			read_remotes_file(remote_state, ret);
 		if (!valid_remote(ret))
 			read_branches_file(remote_state, ret);
 	}
+#endif /* WITH_BREAKING_CHANGES */
 	if (name_given && !valid_remote(ret))
 		add_url_alias(remote_state, ret, name);
 	if (!valid_remote(ret))
diff --git a/remote.h b/remote.h
index a7e5c4e07c53ce5a0f6d852ce9f9233e6bb61550..45b0c9babb1374a05471e86de2c248972adb2aae 100644
--- a/remote.h
+++ b/remote.h
@@ -21,8 +21,10 @@ struct transport_ls_refs_options;
 enum {
 	REMOTE_UNCONFIGURED = 0,
 	REMOTE_CONFIG,
+#ifndef WITH_BREAKING_CHANGES
 	REMOTE_REMOTES,
 	REMOTE_BRANCHES
+#endif /* WITH_BREAKING_CHANGES */
 };
 
 struct rewrite {
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 08424e878e104cc19a43960b987cf868f542cad2..e96ac8c7676ceeb7299c8f0839d9654d527ae084 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1007,7 +1007,7 @@ Pull: refs/heads/main:refs/heads/origin
 Pull: refs/heads/next:refs/heads/origin2
 EOF
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/remotes' '
 	git clone one five &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1033,7 +1033,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches' '
 	git clone --template= one six &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1049,7 +1049,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches (2)' '
 	git clone --template= one seven &&
 	(
 		cd seven &&
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 3b3991ab8678a57fce3ad371e37900fb3c6c426a..04d8a96367910d4687b18a8f725dc365cf2ceedb 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -34,14 +34,11 @@ test_expect_success "clone and setup child repos" '
 	git clone . three &&
 	(
 		cd three &&
-		git config branch.main.remote two &&
-		git config branch.main.merge refs/heads/one &&
-		mkdir -p .git/remotes &&
-		cat >.git/remotes/two <<-\EOF
-		URL: ../two/.git/
-		Pull: refs/heads/main:refs/heads/two
-		Pull: refs/heads/one:refs/heads/one
-		EOF
+		git config set remote.two.url ../two/.git/ &&
+		git config set remote.two.fetch refs/heads/main:refs/heads/two &&
+		git config set --append remote.two.fetch refs/heads/one:refs/heads/one &&
+		git config set branch.main.remote two &&
+		git config set branch.main.merge refs/heads/one
 	) &&
 	git clone . bundle &&
 	git clone . seven
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 320d26796d24d8a2281d37220a7bdf73cafaa503..4e6026c6114fb8367136173ea2b7fdbc0baa37fc 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -104,28 +104,31 @@ test_expect_success setup '
 	git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
 	remotes="$remotes config-glob" &&
 
-	mkdir -p .git/remotes &&
-	cat >.git/remotes/remote-explicit <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/main:remotes/rem/main
-	Pull: refs/heads/one:remotes/rem/one
-	Pull: two:remotes/rem/two
-	Pull: refs/heads/three:remotes/rem/three
-	EOF
-	remotes="$remotes remote-explicit" &&
-
-	cat >.git/remotes/remote-glob <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/*:refs/remotes/rem/*
-	EOF
-	remotes="$remotes remote-glob" &&
-
-	mkdir -p .git/branches &&
-	echo "../.git" > .git/branches/branches-default &&
-	remotes="$remotes branches-default" &&
-
-	echo "../.git#one" > .git/branches/branches-one &&
-	remotes="$remotes branches-one" &&
+	if test_have_prereq WITHOUT_BREAKING_CHANGES
+	then
+		mkdir -p .git/remotes &&
+		cat >.git/remotes/remote-explicit <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/main:remotes/rem/main
+		Pull: refs/heads/one:remotes/rem/one
+		Pull: two:remotes/rem/two
+		Pull: refs/heads/three:remotes/rem/three
+		EOF
+		remotes="$remotes remote-explicit" &&
+
+		cat >.git/remotes/remote-glob <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/*:refs/remotes/rem/*
+		EOF
+		remotes="$remotes remote-glob" &&
+
+		mkdir -p .git/branches &&
+		echo "../.git" > .git/branches/branches-default &&
+		remotes="$remotes branches-default" &&
+
+		echo "../.git#one" > .git/branches/branches-one &&
+		remotes="$remotes branches-one"
+	fi &&
 
 	for remote in $remotes ; do
 		git config branch.br-$remote.remote $remote &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 9d693eb57f7790ddb81cee0b905a101719069562..e705aedbf4a8d57ed188918077b9f82ed8e77b51 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -975,7 +975,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
 	! grep "warning: updating the current branch" stderr
 '
 
-test_expect_success 'fetch with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches' '
 	mk_empty testrepo &&
 	git branch second $the_first_commit &&
 	git checkout second &&
@@ -991,7 +991,7 @@ test_expect_success 'fetch with branches' '
 	git checkout main
 '
 
-test_expect_success 'fetch with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches containing #' '
 	mk_empty testrepo &&
 	mkdir testrepo/.git/branches &&
 	echo "..#second" > testrepo/.git/branches/branch2 &&
@@ -1005,7 +1005,7 @@ test_expect_success 'fetch with branches containing #' '
 	git checkout main
 '
 
-test_expect_success 'push with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches' '
 	mk_empty testrepo &&
 	git checkout second &&
 
@@ -1022,7 +1022,7 @@ test_expect_success 'push with branches' '
 	)
 '
 
-test_expect_success 'push with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches containing #' '
 	mk_empty testrepo &&
 
 	test_when_finished "rm -rf .git/branches" &&
@@ -1211,18 +1211,16 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 '
 
 test_expect_success 'push --prune' '
-	mk_test testrepo heads/main heads/second heads/foo heads/bar &&
+	mk_test testrepo heads/main heads/foo heads/bar &&
 	git push --prune testrepo : &&
 	check_push_result testrepo $the_commit heads/main &&
-	check_push_result testrepo $the_first_commit heads/second &&
 	! check_push_result testrepo $the_first_commit heads/foo heads/bar
 '
 
 test_expect_success 'push --prune refspec' '
-	mk_test testrepo tmp/main tmp/second tmp/foo tmp/bar &&
+	mk_test testrepo tmp/main tmp/foo tmp/bar &&
 	git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
 	check_push_result testrepo $the_commit tmp/main &&
-	check_push_result testrepo $the_first_commit tmp/second &&
 	! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
 '
 
-- 
2.47.1.447.ga7e8429e30.dirty
Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 0/5] remote: announce removal of "branches/" and "remotes/"

Hi,

back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). This mechanism was replaced later that year with the "remotes/" directory. These mechanism have evenutally been replaced by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes. Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011.

This patch series follows through with the deprecation of these and announces them for removal in Git 3.0. Furthermore, it creates the infra to compile Git with such breaking changes enabled and wires up a CI job both for GitHub and GitLab to test those breaking changes.

The series is based on top caacdb5dfd (The fifteenth batch, 2024-12-10) with ps/build at 904339edbd (Introduce support for the Meson build system, 2024-12-06) merged into it.

Changes in v2:
- Some small fixes to the deprecation notice of "branches/" and
  "remotes/".
- Some small fixes to commit messages.
- Link to v1: https://lore.kernel.org/r/20241211-pks-remote-branches-deprecation-v1-0-1431e2369135@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (5):
      Makefile: wire up build option for deprecated features
      ci: merge linux-gcc-default into linux-gcc
      ci: repurpose "linux-gcc" job for deprecations
      builtin/pack-redundant: remove subcommand with breaking changes
      remote: announce removal of "branches/" and "remotes/"
 .github/workflows/main.yml             |  6 +----
 .gitlab-ci.yml                         |  6 +----
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 GIT-BUILD-OPTIONS.in                   |  1 +
 Makefile                               |  7 +++++
 builtin/remote.c                       |  2 ++
 ci/lib.sh                              |  5 ----
 ci/run-build-and-tests.sh              |  3 ++-
 contrib/buildsystems/CMakeLists.txt    |  1 +
 git.c                                  |  2 ++
 meson.build                            |  6 +++++
 meson_options.txt                      |  2 ++
 remote.c                               |  6 +++++
 remote.h                               |  2 ++
 t/t5323-pack-redundant.sh              |  6 +++++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 t/test-lib.sh                          |  4 +++
 21 files changed, 112 insertions(+), 59 deletions(-)
Range-diff versus v1:
1:  51bc2fc09e ! 1:  c15229fb98 Makefile: wire up build option for deprecated features
    @@ Commit message
         breaking changes in the Git project. In 2454970930 (BreakingChanges:
         early adopter option, 2024-10-11) we have amended the document a bit to
         mention that any introduced breaking changes must be accompanied by
    -    logic that allows us to easily enable the breaking change at runtime.
    +    logic that allows us to enable the breaking change at compile-time.
         While we already have two breaking changes lined up, neither of them has
         such a switch because they predate those instructions.
     
2:  71dc627473 = 2:  0131ac856f ci: merge linux-gcc-default into linux-gcc
3:  8134955d0b = 3:  38a71377c0 ci: repurpose "linux-gcc" job for deprecations
4:  aa986122ea = 4:  a8d18e3499 builtin/pack-redundant: remove subcommand with breaking changes
5:  b528488559 ! 5:  7445f06776 remote: announce removal of "branches/" and "remotes/"
    @@ Commit message
     
         Back when Git was in its infancy, remotes were configured via separate
         files in "branches/" (back in 2005). This mechanism was replaced later
    -    that year with the "remotes/" directory. These mechanism have evenutally
    +    that year with the "remotes/" directory. These mechanism have eventually
         been replaced by config-based remotes, and it is very unlikely that
         anybody still uses these directories to configure their remotes.
     
    @@ Documentation/BreakingChanges.txt: Cf. <xmqq1rjuz6n3.fsf_-_@gitster.c.googlers.c
     ++
     +As our documentation mentions, these directories are not to be found in modern
     +repositories at all and most users aren't even aware of these mechanisms. They
    -+have been deprecated for almost 20 years and 14 years respectively, and I am
    ++have been deprecated for almost 20 years and 14 years respectively, and we are
     +not aware of any reason why anybody would want to use these mechanisms.
    -+Furthermore, the ".git/branches/" directory is noadays misleadingly named and
    ++Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
     +may cause confusion as "branches" are almost exclusively used in the context of
     +references.
     ++

--- base-commit: 713ec79a9091cec60b110d605b418904759982ab change-id: 20241205-pks-remote-branches-deprecation-037a4389a377

Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 1/5] Makefile: wire up build option for deprecated features

With 57ec9254eb (docs: introduce document to announce breaking changes, 2024-06-14), we have introduced a new document that tracks upcoming breaking changes in the Git project. In 2454970930 (BreakingChanges: early adopter option, 2024-10-11) we have amended the document a bit to mention that any introduced breaking changes must be accompanied by logic that allows us to enable the breaking change at compile-time. While we already have two breaking changes lined up, neither of them has such a switch because they predate those instructions.

Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and wire it up with both our Makefiles and Meson.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 GIT-BUILD-OPTIONS.in                | 1 +
 Makefile                            | 5 +++++
 contrib/buildsystems/CMakeLists.txt | 1 +
 meson.build                         | 6 ++++++
 meson_options.txt                   | 2 ++
 t/test-lib.sh                       | 4 ++++
 6 files changed, 19 insertions(+)
Show changes to 6 files +19 −0

GIT-BUILD-OPTIONS.in, Makefile, contrib/buildsystems/CMakeLists.txt, meson.build, meson_options.txt, t/test-lib.sh

diff --git a/GIT-BUILD-OPTIONS.in b/GIT-BUILD-OPTIONS.in
index f651116102ae2977622dccd12b199fe7ad65af99..f1d0ecf123031dd13232cc63e100da528bfea16a 100644
--- a/GIT-BUILD-OPTIONS.in
+++ b/GIT-BUILD-OPTIONS.in
@@ -45,3 +45,4 @@ GITWEBDIR=@GITWEBDIR@
 USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
 LOCALEDIR=@LOCALEDIR@
 BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
+WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@
diff --git a/Makefile b/Makefile
index 06f01149ecf399ae4bb1932188a007948d767283..dc3c980aa7a4f42d27ed72415a636ac82b2a5684 100644
--- a/Makefile
+++ b/Makefile
@@ -2230,6 +2230,10 @@ ifdef FSMONITOR_OS_SETTINGS
 	COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
 endif
 
+ifdef WITH_BREAKING_CHANGES
+	BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
@@ -3187,6 +3191,7 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
 		-e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
 		-e "s!@BROKEN_PATH_FIX@!\'$(BROKEN_PATH_FIX)\'!" \
+		-e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 49904ca8a93981c514540bad5efa6833ddd14426..63d008892848c20d5937d9a624a480f700b19498 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
 string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
 string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
 string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
+string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
diff --git a/meson.build b/meson.build
index 0dccebcdf16b07650d943e53643f0e09e2975cc9..316cd9326437876828a88d96a1bc93d503199900 100644
--- a/meson.build
+++ b/meson.build
@@ -644,6 +644,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
 build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
 build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
 
+if get_option('breaking_changes')
+  build_options_config.set('WITH_BREAKING_CHANGES', 'YesPlease')
+else
+  build_options_config.set('WITH_BREAKING_CHANGES', '')
+endif
+
 if get_option('sane_tool_path') != ''
   build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
 else
diff --git a/meson_options.txt b/meson_options.txt
index 32a72139bae870745d9131cc9086a4594826be91..800e518d959c4143812f8840415b99a593667a8d 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -43,6 +43,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
   description: 'The backend used for hashing objects with the SHA256 object format')
 
 # Build tweaks.
+option('breaking_changes', type: 'boolean', value: false,
+  description: 'Enable upcoming breaking changes.')
 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
   description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62dfcc4aaf959d0cf066d07663d939e14f92485c..6e423f655d35adf5a2d4f8b3a78d9e8c1119caab 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
 	curl --version
 '
 
+test_lazy_prereq WITHOUT_BREAKING_CHANGES '
+	test -z "$WITH_BREAKING_CHANGES"
+'
+
 # SHA1 is a test if the hash algorithm in use is SHA-1.  This is both for tests
 # which will not work with other hash algorithms and tests that work but don't
 # test anything meaningful (e.g. special values which cause short collisions).
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Christian Couder· Jan 6, 2025, 13:20 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 1/5] Makefile: wire up build option for deprecated features

On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 12 quoted lines
>
> With 57ec9254eb (docs: introduce document to announce breaking changes,
> 2024-06-14), we have introduced a new document that tracks upcoming
> breaking changes in the Git project. In 2454970930 (BreakingChanges:
> early adopter option, 2024-10-11) we have amended the document a bit to
> mention that any introduced breaking changes must be accompanied by
> logic that allows us to enable the breaking change at compile-time.
> While we already have two breaking changes lined up, neither of them has
> such a switch because they predate those instructions.
>
> Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and
> wire it up with both our Makefiles and Meson.

It's not clear from the above if the two already lined up breaking changes are going to use the new build option in this patch, in a following patch or in a future patch series after this one. Let's see...

[...]
Show 9 quoted lines
> diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
> index 49904ca8a93981c514540bad5efa6833ddd14426..63d008892848c20d5937d9a624a480f700b19498 100644
> --- a/contrib/buildsystems/CMakeLists.txt
> +++ b/contrib/buildsystems/CMakeLists.txt
> @@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
>  string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
>  string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
>  string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
> +string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")

The commit message says that the new build option is wired up with both our Makefiles and Meson, so I didn't expect it to be also wired up with CMake, but it looks like it is.

[...]
Show 11 quoted lines
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 62dfcc4aaf959d0cf066d07663d939e14f92485c..6e423f655d35adf5a2d4f8b3a78d9e8c1119caab 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
>         curl --version
>  '
>
> +test_lazy_prereq WITHOUT_BREAKING_CHANGES '
> +       test -z "$WITH_BREAKING_CHANGES"
> +'
Not expected from reading the commit message, but nice to have too.
Christian Couder· Jan 6, 2025, 13:20 UTC · re: Christian Couder · lore

Re: [PATCH v2 1/5] Makefile: wire up build option for deprecated features

On Mon, Jan 6, 2025 at 12:18 PM Christian Couder <christian.couder@gmail.com> wrote:

Show 19 quoted lines
>
> On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > With 57ec9254eb (docs: introduce document to announce breaking changes,
> > 2024-06-14), we have introduced a new document that tracks upcoming
> > breaking changes in the Git project. In 2454970930 (BreakingChanges:
> > early adopter option, 2024-10-11) we have amended the document a bit to
> > mention that any introduced breaking changes must be accompanied by
> > logic that allows us to enable the breaking change at compile-time.
> > While we already have two breaking changes lined up, neither of them has
> > such a switch because they predate those instructions.
> >
> > Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and
> > wire it up with both our Makefiles and Meson.
>
> It's not clear from the above if the two already lined up breaking
> changes are going to use the new build option in this patch, in a
> following patch or in a future patch series after this one. Let's
> see...
It looks like the two already lined up breaking changes are:
  - removing pack-redundant which is handled in patch 4/5, and
  - removing the "branches/" and "remotes/" directories which is
handled in patch 5/5.
Fine, but I think it would be better to be explicit about this.
Thanks.
Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 2/5] ci: merge linux-gcc-default into linux-gcc

The "linux-gcc-default" job is mostly doing the same as the "linux-gcc" job, except for a couple of minor differences:

  - We use an explicit GCC version instead of the default version
    provided by the distribution. We have other jobs that test with
    "gcc-8", making this distinction pointless.
  - We don't set up the Python version explicitly, and instead use the
    default Python version. Python 2 has been end-of-life for quite a
    while now though, making this distinction less interesting.
  - We set up the default branch name to be "main" in "linux-gcc". We
    have other testcases that don't and also some that explicitly use
    "master".

So overall, the job does not add much to our test coverage. Merge it into our "linux-gcc" job to reduce our test matrix a bit.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 4 ----
 .gitlab-ci.yml             | 4 ----
 ci/lib.sh                  | 5 -----
 3 files changed, 13 deletions(-)
Show changes to 3 files +0 −13

.github/workflows/main.yml, .gitlab-ci.yml, ci/lib.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 808ddc19b8a799abc414c6d6ba078a6e5be6bdfb..32d35d2257812f02121b20c3cae342d626481553 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -271,7 +271,6 @@ jobs:
             pool: ubuntu-latest
           - jobname: linux-gcc
             cc: gcc
-            cc_package: gcc-8
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
             cc: gcc
@@ -286,9 +285,6 @@ jobs:
           - jobname: osx-gcc
             cc: gcc-13
             pool: macos-13
-          - jobname: linux-gcc-default
-            cc: gcc
-            pool: ubuntu-latest
           - jobname: linux-leaks
             cc: gcc
             pool: ubuntu-latest
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a1bc92893f27d6dd404133686b71c8061e55618c..b86bb0bdb3363e06e6fe4195c34babd67cf7e8cc 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,14 +46,10 @@ test:linux:
       - jobname: linux-gcc
         image: ubuntu:20.04
         CC: gcc
-        CC_PACKAGE: gcc-8
       - jobname: linux-TEST-vars
         image: ubuntu:20.04
         CC: gcc
         CC_PACKAGE: gcc-8
-      - jobname: linux-gcc-default
-        image: ubuntu:latest
-        CC: gcc
       - jobname: linux-leaks
         image: ubuntu:latest
         CC: gcc
diff --git a/ci/lib.sh b/ci/lib.sh
index 930f98d7228166c37c236beb062b14675fb68ef3..e67c481d4fe08d0ebc3253a7a832a96f65c79ffe 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -328,11 +328,6 @@ export SKIP_DASHED_BUILT_INS=YesPlease
 
 case "$distro" in
 ubuntu-*)
-	if test "$jobname" = "linux-gcc-default"
-	then
-		break
-	fi
-
 	# Python 2 is end of life, and Ubuntu 23.04 and newer don't actually
 	# have it anymore. We thus only test with Python 2 on older LTS
 	# releases.
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Christian Couder· Jan 6, 2025, 13:25 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 2/5] ci: merge linux-gcc-default into linux-gcc

On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
Show 18 quoted lines
>
> The "linux-gcc-default" job is mostly doing the same as the "linux-gcc"
> job, except for a couple of minor differences:
>
>   - We use an explicit GCC version instead of the default version
>     provided by the distribution. We have other jobs that test with
>     "gcc-8", making this distinction pointless.
>
>   - We don't set up the Python version explicitly, and instead use the
>     default Python version. Python 2 has been end-of-life for quite a
>     while now though, making this distinction less interesting.
>
>   - We set up the default branch name to be "main" in "linux-gcc". We
>     have other testcases that don't and also some that explicitly use
>     "master".
>
> So overall, the job does not add much to our test coverage. Merge it
> into our "linux-gcc" job to reduce our test matrix a bit.

I understand that the subject uses "merge" as the space is limited there, but it might be better to be a bit more explicit here about what the patch is doing, which is:

  - making the "linux-gcc" job use the default version of gcc provided
by the distribution (which is ubuntu-20.04) instead of "gcc-8",
  - removing the "linux-gcc-default" job.
Show 17 quoted lines
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  .github/workflows/main.yml | 4 ----
>  .gitlab-ci.yml             | 4 ----
>  ci/lib.sh                  | 5 -----
>  3 files changed, 13 deletions(-)
>
> diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
> index 808ddc19b8a799abc414c6d6ba078a6e5be6bdfb..32d35d2257812f02121b20c3cae342d626481553 100644
> --- a/.github/workflows/main.yml
> +++ b/.github/workflows/main.yml
> @@ -271,7 +271,6 @@ jobs:
>              pool: ubuntu-latest
>            - jobname: linux-gcc
>              cc: gcc
> -            cc_package: gcc-8
>              pool: ubuntu-20.04
So linux-gcc uses ubuntu-20.04...
Show 9 quoted lines
>            - jobname: linux-TEST-vars
>              cc: gcc
> @@ -286,9 +285,6 @@ jobs:
>            - jobname: osx-gcc
>              cc: gcc-13
>              pool: macos-13
> -          - jobname: linux-gcc-default
> -            cc: gcc
> -            pool: ubuntu-latest
...while linux-gcc-default uses ubuntu-latest.

This is not a big issue but I didn't see that mentioned in the differences between the two jobs listed in the commit message.

Junio C Hamano· Jan 6, 2025, 15:51 UTC · re: Christian Couder · lore

Re: [PATCH v2 2/5] ci: merge linux-gcc-default into linux-gcc

Christian Couder <christian.couder@gmail.com> writes:
Show 27 quoted lines
> On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
>>
>> The "linux-gcc-default" job is mostly doing the same as the "linux-gcc"
>> job, except for a couple of minor differences:
>>
>>   - We use an explicit GCC version instead of the default version
>>     provided by the distribution. We have other jobs that test with
>>     "gcc-8", making this distinction pointless.
>>
>>   - We don't set up the Python version explicitly, and instead use the
>>     default Python version. Python 2 has been end-of-life for quite a
>>     while now though, making this distinction less interesting.
>>
>>   - We set up the default branch name to be "main" in "linux-gcc". We
>>     have other testcases that don't and also some that explicitly use
>>     "master".
>>
>> So overall, the job does not add much to our test coverage. Merge it
>> into our "linux-gcc" job to reduce our test matrix a bit.
>
> I understand that the subject uses "merge" as the space is limited
> there, but it might be better to be a bit more explicit here about
> what the patch is doing, which is:
>
>   - making the "linux-gcc" job use the default version of gcc provided
> by the distribution (which is ubuntu-20.04) instead of "gcc-8",
>   - removing the "linux-gcc-default" job.
unify?  deprecate (the 'default' one)?  

FWIW, I do not think of a better way to phrase what the patch is doing than "merge X into Y".

Thanks.
Patrick Steinhardt· Jan 7, 2025, 12:48 UTC · re: Christian Couder · lore

Re: [PATCH v2 2/5] ci: merge linux-gcc-default into linux-gcc

On Mon, Jan 06, 2025 at 02:25:23PM +0100, Christian Couder wrote:
Show 27 quoted lines
> On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> >
> > The "linux-gcc-default" job is mostly doing the same as the "linux-gcc"
> > job, except for a couple of minor differences:
> >
> >   - We use an explicit GCC version instead of the default version
> >     provided by the distribution. We have other jobs that test with
> >     "gcc-8", making this distinction pointless.
> >
> >   - We don't set up the Python version explicitly, and instead use the
> >     default Python version. Python 2 has been end-of-life for quite a
> >     while now though, making this distinction less interesting.
> >
> >   - We set up the default branch name to be "main" in "linux-gcc". We
> >     have other testcases that don't and also some that explicitly use
> >     "master".
> >
> > So overall, the job does not add much to our test coverage. Merge it
> > into our "linux-gcc" job to reduce our test matrix a bit.
> 
> I understand that the subject uses "merge" as the space is limited
> there, but it might be better to be a bit more explicit here about
> what the patch is doing, which is:
> 
>   - making the "linux-gcc" job use the default version of gcc provided
> by the distribution (which is ubuntu-20.04) instead of "gcc-8",
>   - removing the "linux-gcc-default" job.

But isn't that what "merging" is about? One merges the diff of side A into B and then removes A. I don't have an idea for a better subject, honestly.

Show 34 quoted lines
> > Signed-off-by: Patrick Steinhardt <ps@pks.im>
> > ---
> >  .github/workflows/main.yml | 4 ----
> >  .gitlab-ci.yml             | 4 ----
> >  ci/lib.sh                  | 5 -----
> >  3 files changed, 13 deletions(-)
> >
> > diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
> > index 808ddc19b8a799abc414c6d6ba078a6e5be6bdfb..32d35d2257812f02121b20c3cae342d626481553 100644
> > --- a/.github/workflows/main.yml
> > +++ b/.github/workflows/main.yml
> > @@ -271,7 +271,6 @@ jobs:
> >              pool: ubuntu-latest
> >            - jobname: linux-gcc
> >              cc: gcc
> > -            cc_package: gcc-8
> >              pool: ubuntu-20.04
> 
> So linux-gcc uses ubuntu-20.04...
> 
> >            - jobname: linux-TEST-vars
> >              cc: gcc
> > @@ -286,9 +285,6 @@ jobs:
> >            - jobname: osx-gcc
> >              cc: gcc-13
> >              pool: macos-13
> > -          - jobname: linux-gcc-default
> > -            cc: gcc
> > -            pool: ubuntu-latest
> 
> ...while linux-gcc-default uses ubuntu-latest.
> 
> This is not a big issue but I didn't see that mentioned in the
> differences between the two jobs listed in the commit message.
Fair, added now.
Patrick
Christian Couder· Jan 7, 2025, 13:54 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 2/5] ci: merge linux-gcc-default into linux-gcc

On Tue, Jan 7, 2025 at 1:48 PM Patrick Steinhardt <ps@pks.im> wrote:
Show 33 quoted lines
>
> On Mon, Jan 06, 2025 at 02:25:23PM +0100, Christian Couder wrote:
> > On Mon, Jan 6, 2025 at 8:51 AM Patrick Steinhardt <ps@pks.im> wrote:
> > >
> > > The "linux-gcc-default" job is mostly doing the same as the "linux-gcc"
> > > job, except for a couple of minor differences:
> > >
> > >   - We use an explicit GCC version instead of the default version
> > >     provided by the distribution. We have other jobs that test with
> > >     "gcc-8", making this distinction pointless.
> > >
> > >   - We don't set up the Python version explicitly, and instead use the
> > >     default Python version. Python 2 has been end-of-life for quite a
> > >     while now though, making this distinction less interesting.
> > >
> > >   - We set up the default branch name to be "main" in "linux-gcc". We
> > >     have other testcases that don't and also some that explicitly use
> > >     "master".
> > >
> > > So overall, the job does not add much to our test coverage. Merge it
> > > into our "linux-gcc" job to reduce our test matrix a bit.
> >
> > I understand that the subject uses "merge" as the space is limited
> > there, but it might be better to be a bit more explicit here about
> > what the patch is doing, which is:
> >
> >   - making the "linux-gcc" job use the default version of gcc provided
> > by the distribution (which is ubuntu-20.04) instead of "gcc-8",
> >   - removing the "linux-gcc-default" job.
>
> But isn't that what "merging" is about? One merges the diff of side A
> into B and then removes A. I don't have an idea for a better subject,
> honestly.

My comment was saying that it was fine to use "merge" in the subject, but that, in the body part of the commit message, it would be better if there were more details about what the commit is actually doing.

When the commit message is not clear about what the commit does, it's difficult to check that the changes in the commit were intended.

Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 3/5] ci: repurpose "linux-gcc" job for deprecations

The "linux-gcc" job isn't all that interesting by itself and can be considered more or less the "standard" job: it is running with a reasonably up-to-date image and uses GCC as a compiler, both of which we already cover in other jobs.

There is one exception though: we change the default branch to be "main" instead of "master", so it is forging ahead a bit into the future to make sure that this change does not cause havoc. So let's expand on this a bit and also add the new "WITH_BREAKING_CHANGES" flag to the mix.

Rename the job to "linux-breaking-changes" accordingly.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 2 +-
 .gitlab-ci.yml             | 2 +-
 ci/run-build-and-tests.sh  | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
Show changes to 3 files +4 −3

.github/workflows/main.yml, .gitlab-ci.yml, ci/run-build-and-tests.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 32d35d2257812f02121b20c3cae342d626481553..46b96fb96cc6e2659fe0b4b640f7e671587d059a 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -269,7 +269,7 @@ jobs:
           - jobname: linux-reftable
             cc: clang
             pool: ubuntu-latest
-          - jobname: linux-gcc
+          - jobname: linux-breaking-changes
             cc: gcc
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b86bb0bdb3363e06e6fe4195c34babd67cf7e8cc..492e5d9082dbdb3389c173f2b5a45fe43f4bea41 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -43,7 +43,7 @@ test:linux:
       - jobname: linux-reftable
         image: ubuntu:latest
         CC: clang
-      - jobname: linux-gcc
+      - jobname: linux-breaking-changes
         image: ubuntu:20.04
         CC: gcc
       - jobname: linux-TEST-vars
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 2e28d02b20f2469afddc4e04fdbd18465babb1ef..2ccd812fb4e025be3b8e9ab2ec6ae44e92944ab0 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -13,8 +13,9 @@ esac
 run_tests=t
 
 case "$jobname" in
-linux-gcc)
+linux-breaking-changes)
 	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+	export WITH_BREAKING_CHANGES=YesPlease
 	;;
 linux-TEST-vars)
 	export GIT_TEST_SPLIT_INDEX=yes
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 4/5] builtin/pack-redundant: remove subcommand with breaking changes

The git-pack-redundant(1) subcommand has been announced for removal with 53a92c9552 (Documentation/BreakingChanges: announce removal of git-pack-redundant(1), 2024-09-02). Stop compiling the subcommand in case the `WITH_BREAKING_CHANGES` build flag is set.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Makefile                  | 2 ++
 git.c                     | 2 ++
 t/t5323-pack-redundant.sh | 6 ++++++
 3 files changed, 10 insertions(+)
Show changes to 3 files +10 −0

Makefile, git.c, t/t5323-pack-redundant.sh

diff --git a/Makefile b/Makefile
index dc3c980aa7a4f42d27ed72415a636ac82b2a5684..e6b0d859803ac4d53079ec2a39143441a5662203 100644
--- a/Makefile
+++ b/Makefile
@@ -1278,7 +1278,9 @@ BUILTIN_OBJS += builtin/mv.o
 BUILTIN_OBJS += builtin/name-rev.o
 BUILTIN_OBJS += builtin/notes.o
 BUILTIN_OBJS += builtin/pack-objects.o
+ifndef WITH_BREAKING_CHANGES
 BUILTIN_OBJS += builtin/pack-redundant.o
+endif
 BUILTIN_OBJS += builtin/pack-refs.o
 BUILTIN_OBJS += builtin/patch-id.o
 BUILTIN_OBJS += builtin/prune-packed.o
diff --git a/git.c b/git.c
index 46b3c740c5d665388917c6eee3052cc3ef8368f2..a13c32bcdc694460fcafe8079d3aa6e8caea1b4c 100644
--- a/git.c
+++ b/git.c
@@ -589,7 +589,9 @@ static struct cmd_struct commands[] = {
 	{ "name-rev", cmd_name_rev, RUN_SETUP },
 	{ "notes", cmd_notes, RUN_SETUP },
 	{ "pack-objects", cmd_pack_objects, RUN_SETUP },
+#ifndef WITH_BREAKING_CHANGES
 	{ "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT },
+#endif
 	{ "pack-refs", cmd_pack_refs, RUN_SETUP },
 	{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
 	{ "pickaxe", cmd_blame, RUN_SETUP },
diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
index 8dbbcc5e51c06d7c5f56fcb3107860fcb66a5106..688cd9706c876a7edcaf0bcd642ae08ece188d4d 100755
--- a/t/t5323-pack-redundant.sh
+++ b/t/t5323-pack-redundant.sh
@@ -36,6 +36,12 @@ relationship between packs and objects is as follows:
 
 . ./test-lib.sh
 
+if ! test_have_prereq WITHOUT_BREAKING_CHANGES
+then
+	skip_all='skipping git-pack-redundant tests; built with breaking changes'
+	test_done
+fi
+
 main_repo=main.git
 shared_repo=shared.git
 
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Patrick Steinhardt· Jan 6, 2025, 07:51 UTC · re: Patrick Steinhardt · lore

[PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). This mechanism was replaced later that year with the "remotes/" directory. These mechanism have eventually been replaced by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes.

Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011. Follow through with the deprecation and finally announce the removal of these features in Git 3.0.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 builtin/remote.c                       |  2 ++
 remote.c                               |  6 +++++
 remote.h                               |  2 ++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 9 files changed, 79 insertions(+), 43 deletions(-)
Show changes to 9 files +79 −43

Documentation/BreakingChanges.txt, Documentation/gitrepository-layout.txt, builtin/remote.c, remote.c, remote.h, t/t5505-remote.sh, t/t5510-fetch.sh, t/t5515-fetch-merge-logic.sh, t/t5516-fetch-push.sh

diff --git a/Documentation/BreakingChanges.txt b/Documentation/BreakingChanges.txt
index 27acff86db4883a7d7967343c61711959b75a473..a91eb3bc5518d09b39c49ce07964ca3aba7b11dd 100644
--- a/Documentation/BreakingChanges.txt
+++ b/Documentation/BreakingChanges.txt
@@ -154,6 +154,31 @@ Cf. <xmqq1rjuz6n3.fsf_-_@gitster.c.googlers.com>,
     <CAKvOHKAFXQwt4D8yUCCkf_TQL79mYaJ=KAKhtpDNTvHJFuX1NA@mail.gmail.com>,
     <20230323204047.GA9290@coredump.intra.peff.net>,
 
+* Support for storing shorthands for remote URLs in "$GIT_COMMON_DIR/branches/"
+  and "$GIT_COMMON_DIR/remotes/" has been long superseded by storing remotes in
+  the repository configuration.
++
+The mechanism has originally been introduced in f170e4b39d ([PATCH] fetch/pull:
+short-hand notation for remote repositories., 2005-07-16) and was superseded by
+6687f8fea2 ([PATCH] Use .git/remote/origin, not .git/branches/origin.,
+2005-08-20), where we switched from ".git/branches/" to ".git/remotes/". That
+commit already mentions an upcoming deprecation of the ".git/branches/"
+directory, and starting with a1d4aa7424 (Add repository-layout document.,
+2005-09-01) we have also marked this layout as deprecated. Eventually we also
+started to migrate away from ".git/remotes/" in favor of config-based remotes,
+and we have marked the directory as legacy in 3d3d282146 (Documentation:
+Grammar correction, wording fixes and cleanup, 2011-08-23)
++
+As our documentation mentions, these directories are not to be found in modern
+repositories at all and most users aren't even aware of these mechanisms. They
+have been deprecated for almost 20 years and 14 years respectively, and we are
+not aware of any reason why anybody would want to use these mechanisms.
+Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
+may cause confusion as "branches" are almost exclusively used in the context of
+references.
++
+These features will be removed.
+
 == Superseded features that will not be deprecated
 
 Some features have gained newer replacements that aim to improve the design in
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index fa8b51daf08775f3d666a910d9b00486627e02af..85911ca8ea0b222ab9cc3dc2dd99c5136c72bd2b 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -153,7 +153,7 @@ config.worktree::
 	linkgit:git-worktree[1]).
 
 branches::
-	A slightly deprecated way to store shorthands to be used
+	A deprecated way to store shorthands to be used
 	to specify a URL to 'git fetch', 'git pull' and 'git push'.
 	A file can be stored as `branches/<name>` and then
 	'name' can be given to these commands in place of
@@ -162,7 +162,8 @@ branches::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/branches" will be used instead.
-
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 hooks::
 	Hooks are customization scripts used by various Git
@@ -238,6 +239,8 @@ remotes::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/remotes" will be used instead.
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 logs::
 	Records of changes made to refs are stored in this directory.
diff --git a/builtin/remote.c b/builtin/remote.c
index 1ad3e70a6b438a3c4446b16c02dc5c23c7fa14be..e565b2b3fec8bf2e4182e85d8d08953a14416881 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -640,10 +640,12 @@ static int migrate_file(struct remote *remote)
 	strbuf_addf(&buf, "remote.%s.fetch", remote->name);
 	for (i = 0; i < remote->fetch.nr; i++)
 		git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (remote->origin == REMOTE_REMOTES)
 		unlink_or_warn(git_path("remotes/%s", remote->name));
 	else if (remote->origin == REMOTE_BRANCHES)
 		unlink_or_warn(git_path("branches/%s", remote->name));
+#endif /* WITH_BREAKING_CHANGES */
 	strbuf_release(&buf);
 
 	return 0;
diff --git a/remote.c b/remote.c
index 10104d11e3cba1908cd35f22b54e167755770404..55e91fab47197313fd8c2c1c5f73fcd46b4df4f7 100644
--- a/remote.c
+++ b/remote.c
@@ -293,6 +293,7 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
 	rewrite->instead_of_nr++;
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static const char *skip_spaces(const char *s)
 {
 	while (isspace(*s))
@@ -374,6 +375,7 @@ static void read_branches_file(struct remote_state *remote_state,
 	strbuf_release(&buf);
 	free(to_free);
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static int handle_config(const char *key, const char *value,
 			 const struct config_context *ctx, void *cb)
@@ -572,6 +574,7 @@ static void read_config(struct repository *repo, int early)
 	alias_all_urls(repo->remote_state);
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static int valid_remote_nick(const char *name)
 {
 	if (!name[0] || is_dot_or_dotdot(name))
@@ -583,6 +586,7 @@ static int valid_remote_nick(const char *name)
 			return 0;
 	return 1;
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static const char *remotes_remote_for_branch(struct remote_state *remote_state,
 					     struct branch *branch,
@@ -725,12 +729,14 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
 				   &name_given);
 
 	ret = make_remote(remote_state, name, 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (valid_remote_nick(name) && have_git_dir()) {
 		if (!valid_remote(ret))
 			read_remotes_file(remote_state, ret);
 		if (!valid_remote(ret))
 			read_branches_file(remote_state, ret);
 	}
+#endif /* WITH_BREAKING_CHANGES */
 	if (name_given && !valid_remote(ret))
 		add_url_alias(remote_state, ret, name);
 	if (!valid_remote(ret))
diff --git a/remote.h b/remote.h
index a7e5c4e07c53ce5a0f6d852ce9f9233e6bb61550..45b0c9babb1374a05471e86de2c248972adb2aae 100644
--- a/remote.h
+++ b/remote.h
@@ -21,8 +21,10 @@ struct transport_ls_refs_options;
 enum {
 	REMOTE_UNCONFIGURED = 0,
 	REMOTE_CONFIG,
+#ifndef WITH_BREAKING_CHANGES
 	REMOTE_REMOTES,
 	REMOTE_BRANCHES
+#endif /* WITH_BREAKING_CHANGES */
 };
 
 struct rewrite {
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 08424e878e104cc19a43960b987cf868f542cad2..e96ac8c7676ceeb7299c8f0839d9654d527ae084 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1007,7 +1007,7 @@ Pull: refs/heads/main:refs/heads/origin
 Pull: refs/heads/next:refs/heads/origin2
 EOF
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/remotes' '
 	git clone one five &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1033,7 +1033,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches' '
 	git clone --template= one six &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1049,7 +1049,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches (2)' '
 	git clone --template= one seven &&
 	(
 		cd seven &&
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 3b3991ab8678a57fce3ad371e37900fb3c6c426a..04d8a96367910d4687b18a8f725dc365cf2ceedb 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -34,14 +34,11 @@ test_expect_success "clone and setup child repos" '
 	git clone . three &&
 	(
 		cd three &&
-		git config branch.main.remote two &&
-		git config branch.main.merge refs/heads/one &&
-		mkdir -p .git/remotes &&
-		cat >.git/remotes/two <<-\EOF
-		URL: ../two/.git/
-		Pull: refs/heads/main:refs/heads/two
-		Pull: refs/heads/one:refs/heads/one
-		EOF
+		git config set remote.two.url ../two/.git/ &&
+		git config set remote.two.fetch refs/heads/main:refs/heads/two &&
+		git config set --append remote.two.fetch refs/heads/one:refs/heads/one &&
+		git config set branch.main.remote two &&
+		git config set branch.main.merge refs/heads/one
 	) &&
 	git clone . bundle &&
 	git clone . seven
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 320d26796d24d8a2281d37220a7bdf73cafaa503..4e6026c6114fb8367136173ea2b7fdbc0baa37fc 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -104,28 +104,31 @@ test_expect_success setup '
 	git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
 	remotes="$remotes config-glob" &&
 
-	mkdir -p .git/remotes &&
-	cat >.git/remotes/remote-explicit <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/main:remotes/rem/main
-	Pull: refs/heads/one:remotes/rem/one
-	Pull: two:remotes/rem/two
-	Pull: refs/heads/three:remotes/rem/three
-	EOF
-	remotes="$remotes remote-explicit" &&
-
-	cat >.git/remotes/remote-glob <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/*:refs/remotes/rem/*
-	EOF
-	remotes="$remotes remote-glob" &&
-
-	mkdir -p .git/branches &&
-	echo "../.git" > .git/branches/branches-default &&
-	remotes="$remotes branches-default" &&
-
-	echo "../.git#one" > .git/branches/branches-one &&
-	remotes="$remotes branches-one" &&
+	if test_have_prereq WITHOUT_BREAKING_CHANGES
+	then
+		mkdir -p .git/remotes &&
+		cat >.git/remotes/remote-explicit <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/main:remotes/rem/main
+		Pull: refs/heads/one:remotes/rem/one
+		Pull: two:remotes/rem/two
+		Pull: refs/heads/three:remotes/rem/three
+		EOF
+		remotes="$remotes remote-explicit" &&
+
+		cat >.git/remotes/remote-glob <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/*:refs/remotes/rem/*
+		EOF
+		remotes="$remotes remote-glob" &&
+
+		mkdir -p .git/branches &&
+		echo "../.git" > .git/branches/branches-default &&
+		remotes="$remotes branches-default" &&
+
+		echo "../.git#one" > .git/branches/branches-one &&
+		remotes="$remotes branches-one"
+	fi &&
 
 	for remote in $remotes ; do
 		git config branch.br-$remote.remote $remote &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 9d693eb57f7790ddb81cee0b905a101719069562..e705aedbf4a8d57ed188918077b9f82ed8e77b51 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -975,7 +975,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
 	! grep "warning: updating the current branch" stderr
 '
 
-test_expect_success 'fetch with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches' '
 	mk_empty testrepo &&
 	git branch second $the_first_commit &&
 	git checkout second &&
@@ -991,7 +991,7 @@ test_expect_success 'fetch with branches' '
 	git checkout main
 '
 
-test_expect_success 'fetch with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches containing #' '
 	mk_empty testrepo &&
 	mkdir testrepo/.git/branches &&
 	echo "..#second" > testrepo/.git/branches/branch2 &&
@@ -1005,7 +1005,7 @@ test_expect_success 'fetch with branches containing #' '
 	git checkout main
 '
 
-test_expect_success 'push with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches' '
 	mk_empty testrepo &&
 	git checkout second &&
 
@@ -1022,7 +1022,7 @@ test_expect_success 'push with branches' '
 	)
 '
 
-test_expect_success 'push with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches containing #' '
 	mk_empty testrepo &&
 
 	test_when_finished "rm -rf .git/branches" &&
@@ -1211,18 +1211,16 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 '
 
 test_expect_success 'push --prune' '
-	mk_test testrepo heads/main heads/second heads/foo heads/bar &&
+	mk_test testrepo heads/main heads/foo heads/bar &&
 	git push --prune testrepo : &&
 	check_push_result testrepo $the_commit heads/main &&
-	check_push_result testrepo $the_first_commit heads/second &&
 	! check_push_result testrepo $the_first_commit heads/foo heads/bar
 '
 
 test_expect_success 'push --prune refspec' '
-	mk_test testrepo tmp/main tmp/second tmp/foo tmp/bar &&
+	mk_test testrepo tmp/main tmp/foo tmp/bar &&
 	git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
 	check_push_result testrepo $the_commit tmp/main &&
-	check_push_result testrepo $the_first_commit tmp/second &&
 	! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
 '
 
-- 
2.48.0.rc1.245.gb3e6e7acbc.dirty
Christian Couder· Jan 6, 2025, 13:24 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On Mon, Jan 6, 2025 at 8:52 AM Patrick Steinhardt <ps@pks.im> wrote:
>
> Back when Git was in its infancy, remotes were configured via separate
> files in "branches/" (back in 2005). This mechanism was replaced later
> that year with the "remotes/" directory. These mechanism have eventually
s/mechanism/mechanisms/
Show 6 quoted lines
> been replaced by config-based remotes, and it is very unlikely that
> anybody still uses these directories to configure their remotes.
>
> Both of these directories have been marked as deprecated, one in 2005
> and the other one in 2011. Follow through with the deprecation and
> finally announce the removal of these features in Git 3.0.

What I like about the removal of git-pack-redundant(1) in the previous patch is that we started to emit a user-visible warning in 2020 and now users even have to pass an `--i-still-use-this` option to be able to use the command. This really makes sure users cannot ignore the fact that the command is deprecated.

Accordingly I think it would be nice if we started to emit warnings (that could possibly be disabled) when we find a repo still uses stuff in "branches/" and "remotes/". These would be much more difficult to miss or ignore than doc changes.

Junio C Hamano· Jan 6, 2025, 15:53 UTC · re: Christian Couder · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Christian Couder <christian.couder@gmail.com> writes:
Show 10 quoted lines
> What I like about the removal of git-pack-redundant(1) in the previous
> patch is that we started to emit a user-visible warning in 2020 and
> now users even have to pass an `--i-still-use-this` option to be able
> to use the command. This really makes sure users cannot ignore the
> fact that the command is deprecated.
>
> Accordingly I think it would be nice if we started to emit warnings
> (that could possibly be disabled) when we find a repo still uses stuff
> in "branches/" and "remotes/". These would be much more difficult to
> miss or ignore than doc changes.

That's an excellent suggestion. Even though this topic is about introducing breaking changes, saying "we waited for long enough", making sure we have prepared the user base for such changes to lesson the impact of "breaking" changes is a very prudent thing to do.

I guess everything is contained within remote.c these days? Patches welcome ;-)

Thanks.
Patrick Steinhardt· Jan 7, 2025, 12:48 UTC · re: Junio C Hamano · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On Mon, Jan 06, 2025 at 07:53:46AM -0800, Junio C Hamano wrote:
Show 21 quoted lines
> Christian Couder <christian.couder@gmail.com> writes:
> 
> > What I like about the removal of git-pack-redundant(1) in the previous
> > patch is that we started to emit a user-visible warning in 2020 and
> > now users even have to pass an `--i-still-use-this` option to be able
> > to use the command. This really makes sure users cannot ignore the
> > fact that the command is deprecated.
> >
> > Accordingly I think it would be nice if we started to emit warnings
> > (that could possibly be disabled) when we find a repo still uses stuff
> > in "branches/" and "remotes/". These would be much more difficult to
> > miss or ignore than doc changes.
> 
> That's an excellent suggestion.  Even though this topic is about
> introducing breaking changes, saying "we waited for long enough",
> making sure we have prepared the user base for such changes to
> lesson the impact of "breaking" changes is a very prudent thing to
> do.
> 
> I guess everything is contained within remote.c these days?
> Patches welcome ;-)

Makes sense indeed. We can easily add for something like below diff. I'll roll that into the next version, thanks!

Patrick
Show changes to remote.c +13 −0
diff --git a/remote.c b/remote.c
index 55e91fab47..8c104c6ee1 100644
--- a/remote.c
+++ b/remote.c
@@ -309,6 +309,13 @@ static void read_remotes_file(struct remote_state *remote_state,
 
 	if (!f)
 		return;
+
+	warning(_("Reading remote from \"remotes/%s\", which is nominated\n"
+		  "for removal. If you still use the \"remotes/\" directory\n"
+		  "it is recommended to migrate to config-based remotes. If\n"
+		  "you cannot, please let us know you still use it by sending\n"
+		  "an e-mail to <git@vger.kernel.org>."), remote->name);
+
 	remote->configured_in_repo = 1;
 	remote->origin = REMOTE_REMOTES;
 	while (strbuf_getline(&buf, f) != EOF) {
@@ -338,6 +345,12 @@ static void read_branches_file(struct remote_state *remote_state,
 	if (!f)
 		return;
 
+	warning(_("Reading remote from \"branches/%s\", which is nominated\n"
+		  "for removal. If you still use the \"branches/\" directory\n"
+		  "it is recommended to migrate to config-based remotes. If\n"
+		  "you cannot, please let us know you still use it by sending\n"
+		  "an e-mail to <git@vger.kernel.org>."), remote->name);
+
 	strbuf_getline_lf(&buf, f);
 	fclose(f);
 	strbuf_trim(&buf);
Junio C Hamano· Jan 7, 2025, 16:40 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
> Makes sense indeed. We can easily add for something like below diff.
> I'll roll that into the next version, thanks!

It is a good start, but is probably a bit too noisy. Can we make them appear ONLY when the definitions read from these older sources are actually USED?

Thanks.
Show 34 quoted lines
>
> Patrick
>
> diff --git a/remote.c b/remote.c
> index 55e91fab47..8c104c6ee1 100644
> --- a/remote.c
> +++ b/remote.c
> @@ -309,6 +309,13 @@ static void read_remotes_file(struct remote_state *remote_state,
>  
>  	if (!f)
>  		return;
> +
> +	warning(_("Reading remote from \"remotes/%s\", which is nominated\n"
> +		  "for removal. If you still use the \"remotes/\" directory\n"
> +		  "it is recommended to migrate to config-based remotes. If\n"
> +		  "you cannot, please let us know you still use it by sending\n"
> +		  "an e-mail to <git@vger.kernel.org>."), remote->name);
> +
>  	remote->configured_in_repo = 1;
>  	remote->origin = REMOTE_REMOTES;
>  	while (strbuf_getline(&buf, f) != EOF) {
> @@ -338,6 +345,12 @@ static void read_branches_file(struct remote_state *remote_state,
>  	if (!f)
>  		return;
>  
> +	warning(_("Reading remote from \"branches/%s\", which is nominated\n"
> +		  "for removal. If you still use the \"branches/\" directory\n"
> +		  "it is recommended to migrate to config-based remotes. If\n"
> +		  "you cannot, please let us know you still use it by sending\n"
> +		  "an e-mail to <git@vger.kernel.org>."), remote->name);
> +
>  	strbuf_getline_lf(&buf, f);
>  	fclose(f);
>  	strbuf_trim(&buf);
Junio C Hamano· Jan 7, 2025, 16:49 UTC · re: Junio C Hamano · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Junio C Hamano <gitster@pobox.com> writes:
Show 10 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
>
>> Makes sense indeed. We can easily add for something like below diff.
>> I'll roll that into the next version, thanks!
>
> It is a good start, but is probably a bit too noisy.  Can we make
> them appear ONLY when the definitions read from these older sources
> are actually USED?
>
> Thanks.

Something along this line is what I had in mind. Not even compile tested, and I am not claiming that all the uses of remote will go thourgh the code paths to use it with a transport, but you hopefully got the idea.

 remote.c    | 20 ++++++++++++++++++++
 remote.h    |  2 ++
 transport.c |  2 ++
 3 files changed, 24 insertions(+)
Show changes to diff +24 −0
diff --git c/remote.c w/remote.c
index f43cf5e7a4..1cca98215d 100644
--- c/remote.c
+++ w/remote.c
@@ -2904,3 +2904,23 @@ char *relative_url(const char *remote_url, const char *url,
 	free(out);
 	return strbuf_detach(&sb, NULL);
 }
+
+void remote_stale_warning(const struct remote *remote)
+{
+	const char *msg;
+
+	switch (remote->origin) {
+	case REMOTE_REMOTES:
+		msg = N_("Using remote '%s' read from the .git/remotes, "
+			 "whose support will be removed");
+		break;
+	case REMOTE_BRANCHES:
+		msg = N_("Using remote '%s' read from the .git/branches, "
+			 "whose support will be removed");
+		break;
+	default:
+		return;
+	}
+
+	warning(_(msg), remote->name);
+}
diff --git c/remote.h w/remote.h
index b901b56746..e29ceef3e4 100644
--- c/remote.h
+++ w/remote.h
@@ -445,4 +445,6 @@ void apply_push_cas(struct push_cas_option *, struct remote *, struct ref *);
 char *relative_url(const char *remote_url, const char *url,
 		   const char *up_path);
 
+void remote_stale_warning(const struct remote *remote);
+
 #endif
diff --git c/transport.c w/transport.c
index 12cc5b4d96..c153be9100 100644
--- c/transport.c
+++ w/transport.c
@@ -1131,6 +1131,8 @@ struct transport *transport_get(struct remote *remote, const char *url)
 	ret->remote = remote;
 	helper = remote->foreign_vcs;
 
+	remote_stale_warning(remote);
+
 	if (!url)
 		url = remote->url.v[0];
 	ret->url = url;
rsbecker@nexbridge.com· Jan 7, 2025, 16:55 UTC · re: Junio C Hamano · lore

RE: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On January 7, 2025 11:50 AM, Junio C Hamano wrote:
Show 14 quoted lines
>Junio C Hamano <gitster@pobox.com> writes:
>
>> Patrick Steinhardt <ps@pks.im> writes:
>>
>>> Makes sense indeed. We can easily add for something like below diff.
>>> I'll roll that into the next version, thanks!
>>
>> It is a good start, but is probably a bit too noisy.  Can we make them
>> appear ONLY when the definitions read from these older sources are
>> actually USED?
>>
>> Thanks.
>
>Something along this line is what I had in mind.  Not even compile tested,
and I am
>not claiming that all the uses of remote will go thourgh the code paths to
use it with
Show 12 quoted lines
>a transport, but you hopefully got the idea.
>
> remote.c    | 20 ++++++++++++++++++++
> remote.h    |  2 ++
> transport.c |  2 ++
> 3 files changed, 24 insertions(+)
>
>diff --git c/remote.c w/remote.c
>index f43cf5e7a4..1cca98215d 100644
>--- c/remote.c
>+++ w/remote.c
>@@ -2904,3 +2904,23 @@ char *relative_url(const char *remote_url, const
char
Show 29 quoted lines
>*url,
> 	free(out);
> 	return strbuf_detach(&sb, NULL);
> }
>+
>+void remote_stale_warning(const struct remote *remote) {
>+	const char *msg;
>+
>+	switch (remote->origin) {
>+	case REMOTE_REMOTES:
>+		msg = N_("Using remote '%s' read from the .git/remotes, "
>+			 "whose support will be removed");
>+		break;
>+	case REMOTE_BRANCHES:
>+		msg = N_("Using remote '%s' read from the .git/branches, "
>+			 "whose support will be removed");
>+		break;
>+	default:
>+		return;
>+	}
>+
>+	warning(_(msg), remote->name);
>+}
>diff --git c/remote.h w/remote.h
>index b901b56746..e29ceef3e4 100644
>--- c/remote.h
>+++ w/remote.h
>@@ -445,4 +445,6 @@ void apply_push_cas(struct push_cas_option *, struct
>remote *, struct ref *);  char *relative_url(const char *remote_url, const
char *url,
Show 10 quoted lines
> 		   const char *up_path);
>
>+void remote_stale_warning(const struct remote *remote);
>+
> #endif
>diff --git c/transport.c w/transport.c
>index 12cc5b4d96..c153be9100 100644
>--- c/transport.c
>+++ w/transport.c
>@@ -1131,6 +1131,8 @@ struct transport *transport_get(struct remote
*remote,
Show 9 quoted lines
>const char *url)
> 	ret->remote = remote;
> 	helper = remote->foreign_vcs;
>
>+	remote_stale_warning(remote);
>+
> 	if (!url)
> 		url = remote->url.v[0];
> 	ret->url = url;

I like this but wonder whether there might be some way to inhibit the warnings one a user gets it and decides they will act but do not want to see the warnings any longer? I have had requests like this on other products. Just a thought.

Patrick Steinhardt· Jan 8, 2025, 06:36 UTC · re: rsbecker@nexbridge.com · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On Tue, Jan 07, 2025 at 11:55:16AM -0500, rsbecker@nexbridge.com wrote:
Show 13 quoted lines
> On January 7, 2025 11:50 AM, Junio C Hamano wrote:
> >Junio C Hamano <gitster@pobox.com> writes:
> >
> >> Patrick Steinhardt <ps@pks.im> writes:
> >>
> >>> Makes sense indeed. We can easily add for something like below diff.
> >>> I'll roll that into the next version, thanks!
> >>
> >> It is a good start, but is probably a bit too noisy.  Can we make them
> >> appear ONLY when the definitions read from these older sources are
> >> actually USED?
> >>
> >> Thanks.
Fair enough, can do.
> I like this but wonder whether there might be some way to inhibit the
> warnings one a user gets it and decides they will act but do not want
> to see the warnings any longer? I have had requests like this on other
> products. Just a thought.

I guess the best idea I have here is to use an environment variable, e.g. "GIT_ALLOW_DEPRECATED_REMOTES=true", along with a hint for how to enable it.

Patrick
Junio C Hamano· Jan 8, 2025, 17:09 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
Show 10 quoted lines
> On Tue, Jan 07, 2025 at 11:55:16AM -0500, rsbecker@nexbridge.com wrote:
>
>> I like this but wonder whether there might be some way to inhibit the
>> warnings one a user gets it and decides they will act but do not want
>> to see the warnings any longer? I have had requests like this on other
>> products. Just a thought.
>
> I guess the best idea I have here is to use an environment variable,
> e.g. "GIT_ALLOW_DEPRECATED_REMOTES=true", along with a hint for how to
> enable it.
Hmph.

I may be missing something, but wouldn't the whole point of the warning be noisy and pesky as long as the user _uses_ that configuration? It is not like "you can set this knob and delay the removal past Git 3.0". If the user migrates away from the mechanism that is being removed, we would stop bugging the user about the stale setting, so I do not see why we want to add anything extra (other than possibly telling them how to migrate away from $GIT_DIR/{branches,remotes}/ using "git remote" in the warning message itself).

Thanks.
Patrick Steinhardt· Jan 9, 2025, 10:06 UTC · re: Junio C Hamano · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On Wed, Jan 08, 2025 at 09:09:28AM -0800, Junio C Hamano wrote:
Show 24 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > On Tue, Jan 07, 2025 at 11:55:16AM -0500, rsbecker@nexbridge.com wrote:
> >
> >> I like this but wonder whether there might be some way to inhibit the
> >> warnings one a user gets it and decides they will act but do not want
> >> to see the warnings any longer? I have had requests like this on other
> >> products. Just a thought.
> >
> > I guess the best idea I have here is to use an environment variable,
> > e.g. "GIT_ALLOW_DEPRECATED_REMOTES=true", along with a hint for how to
> > enable it.
> 
> Hmph.
> 
> I may be missing something, but wouldn't the whole point of the
> warning be noisy and pesky as long as the user _uses_ that
> configuration?  It is not like "you can set this knob and delay the
> removal past Git 3.0".  If the user migrates away from the mechanism
> that is being removed, we would stop bugging the user about the
> stale setting, so I do not see why we want to add anything extra
> (other than possibly telling them how to migrate away from
> $GIT_DIR/{branches,remotes}/ using "git remote" in the warning
> message itself).

Sure, that would be the intent. But it may take the user a bit of time to do the migration, and meanwhile they may want to silence the warning. It's not like we'll release Git 3.0 tomorrow, it will probably take us a while to get there, which gives people a bit of time to migrate.

I'm also happy to just leave it out though, I don't mind too much.
Patrick
Robert Coup· Jan 9, 2025, 12:08 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Hi Patrick,
On Wed, 8 Jan 2025 at 06:36, Patrick Steinhardt <ps@pks.im> wrote:
Show 11 quoted lines
>
> On Tue, Jan 07, 2025 at 11:55:16AM -0500, rsbecker@nexbridge.com wrote:
>
> > I like this but wonder whether there might be some way to inhibit the
> > warnings one a user gets it and decides they will act but do not want
> > to see the warnings any longer? I have had requests like this on other
> > products. Just a thought.
>
> I guess the best idea I have here is to use an environment variable,
> e.g. "GIT_ALLOW_DEPRECATED_REMOTES=true", along with a hint for how to
> enable it.

Since there will hopefully be several of these deprecated behaviours as 3.0 comes closer, rather than adding a tonne of variables should it be a consistent method of silencing warnings? eg: "GIT_IGNORE_DEPRECATION_WARNINGS=remotes:splines:llamas". And/or achieving it via config settings.

Rob :)
Patrick Steinhardt· Jan 9, 2025, 10:20 UTC · re: Junio C Hamano · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

On Tue, Jan 07, 2025 at 08:49:37AM -0800, Junio C Hamano wrote:
Show 17 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Patrick Steinhardt <ps@pks.im> writes:
> >
> >> Makes sense indeed. We can easily add for something like below diff.
> >> I'll roll that into the next version, thanks!
> >
> > It is a good start, but is probably a bit too noisy.  Can we make
> > them appear ONLY when the definitions read from these older sources
> > are actually USED?
> >
> > Thanks.
> 
> Something along this line is what I had in mind.  Not even compile
> tested, and I am not claiming that all the uses of remote will go
> thourgh the code paths to use it with a transport, but you hopefully
> got the idea.

I had a look at your idea now, but I'm not convinced that it would be a significantly improvement over my version. In almost all cases where we execute `remote_get()` we'd also end up using the remote itself. So we'd either have to add the explicit warning to all such locations, or we risk not warning in cases where we really should.

The result of `remote_get()` (and `remotes_remote_get()`) is also being cached, so if we retrieve the same remote multiple times from the same remote state we'd only see the warning once.

So I'm inclined to leave this as-is, maybe adding an escape hatch to silence the warnings via an environment variable to give users a bit of time to migrate.

Patrick
Junio C Hamano· Jan 9, 2025, 15:54 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 5/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
> So I'm inclined to leave this as-is, maybe adding an escape hatch to
> silence the warnings via an environment variable to give users a bit of
> time to migrate.

OK. I strongly prefer simpler implementation, as long as it won't make end-user experience (over time across Git 3.0 boundary) overly unpleasant.

Numbing the pain for short-term gain and letting the inevitable removal (not deprecation) suddenly hit them is also extremely unpleasant at Git 3.0 boundary, and such a pain is probably a problem of their own creation, but I learned after Git 1.6 fiasco that users always blame us for their own failings, so I still am fairly reluctant to see us offer a way to squelch the warnings too easily and forget about it.

Thanks.
Junio C Hamano· Jan 6, 2025, 15:42 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 0/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
> back when Git was in its infancy, remotes were configured via separate
> files in "branches/" (back in 2005). This mechanism was replaced later
> that year with the "remotes/" directory. These mechanism have evenutally
> been replaced by config-based remotes,...

Just a historical note, as I am not sure how much of it still matters. In all of the above "replaced" is an incorrect verb to use. "A more-powerful-but-different mechanism to do the same and more was introduced later" is a fair statement, though.

Specifically the ".git/branches/name" mechanism was never removed as it had one distinct advantage over all other mechanisms for users who have to juggle tons of remotes that change either their URLs or branch names or both not so infrequently. Instead of having to edit files in .git/remotes/*, being able to say

	$ ls .git/branches/*partialname*
	$ echo "$URL#$branch" >.git/branches/foo
	$ rm .git/brnaches/foo

was powerful. Offhand I do not know if "git remote" command improved the usability aspect of newer mechanisms good enough to allow us to start using the verb "replace" here.

Patrick Steinhardt· Jan 7, 2025, 12:48 UTC · re: Junio C Hamano · lore

Re: [PATCH v2 0/5] remote: announce removal of "branches/" and "remotes/"

On Mon, Jan 06, 2025 at 07:42:25AM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > back when Git was in its infancy, remotes were configured via separate
> > files in "branches/" (back in 2005). This mechanism was replaced later
> > that year with the "remotes/" directory. These mechanism have evenutally
> > been replaced by config-based remotes,...
> 
> Just a historical note, as I am not sure how much of it still
> matters.  In all of the above "replaced" is an incorrect verb to
> use.  "A more-powerful-but-different mechanism to do the same and
> more was introduced later" is a fair statement, though.
> 
> Specifically the ".git/branches/name" mechanism was never removed as
> it had one distinct advantage over all other mechanisms for users
> who have to juggle tons of remotes that change either their URLs or
> branch names or both not so infrequently.  Instead of having to edit
> files in .git/remotes/*, being able to say
> 
> 	$ ls .git/branches/*partialname*
> 	$ echo "$URL#$branch" >.git/branches/foo
> 	$ rm .git/brnaches/foo
> 
> was powerful.  Offhand I do not know if "git remote" command
> improved the usability aspect of newer mechanisms good enough
> to allow us to start using the verb "replace" here.

I would claim the fact that nobody nowadays knows about either of the old mechanisms is a good indicator that git-remote(1) has indeed completely replaced them. I'm happy to slightly reword it though, even if it doesn't ultimately end up in any of the commits anyway :)

Patrick
Junio C Hamano· Jan 7, 2025, 16:36 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v2 0/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
Show 18 quoted lines
>> Specifically the ".git/branches/name" mechanism was never removed as
>> it had one distinct advantage over all other mechanisms for users
>> who have to juggle tons of remotes that change either their URLs or
>> branch names or both not so infrequently.  Instead of having to edit
>> files in .git/remotes/*, being able to say
>> 
>> 	$ ls .git/branches/*partialname*
>> 	$ echo "$URL#$branch" >.git/branches/foo
>> 	$ rm .git/brnaches/foo
>> 
>> was powerful.  Offhand I do not know if "git remote" command
>> improved the usability aspect of newer mechanisms good enough
>> to allow us to start using the verb "replace" here.
>
> I would claim the fact that nobody nowadays knows about either of the
> old mechanisms is a good indicator that git-remote(1) has indeed
> completely replaced them. I'm happy to slightly reword it though, even
> if it doesn't ultimately end up in any of the commits anyway :)

We can claim whatever, but scripts written in ancient days may still know about them and they do not care what we claim. And that is the primary thing that makes me worried.

As suggested elsewhere, I think it is prudent to add some checks when remote.c notices that we used the values that were read via these old mechanims and complain loudly.

Thanks.
Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 0/5] remote: announce removal of "branches/" and "remotes/"

Hi,

back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). Later that year we introduced a more powerful mechanism with the "remotes/" directory. These mechanism have eventually been superseded by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes. Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011.

This patch series follows through with the deprecation of these and announces them for removal in Git 3.0. Furthermore, it creates the infra to compile Git with such breaking changes enabled and wires up a CI job both for GitHub and GitLab to test those breaking changes.

The series is based on top caacdb5dfd (The fifteenth batch, 2024-12-10) with ps/build at 904339edbd (Introduce support for the Meson build system, 2024-12-06) merged into it.

Changes in v2:
- Some small fixes to the deprecation notice of "branches/" and
  "remotes/".
- Some small fixes to commit messages.
- Link to v1: https://lore.kernel.org/r/20241211-pks-remote-branches-deprecation-v1-0-1431e2369135@pks.im
Changes in v3:
- Print warnings when reading remotes from "remotes/" or "branches/".
- A couple of commit mesasge improvements.
- Link to v2: https://lore.kernel.org/r/20250106-pks-remote-branches-deprecation-v2-0-2ce87c053536@pks.im
Changes in v4:
- Add migration instructions to the warning when reading deprecated
  remote types.
- Clarify the deprecation text a bit.
- Link to v3: https://lore.kernel.org/r/20250120-pks-remote-branches-deprecation-v3-0-c7e539b6a84f@pks.im
Thanks!
Patrick
---
Patrick Steinhardt (5):
      Makefile: wire up build option for deprecated features
      ci: merge linux-gcc-default into linux-gcc
      ci: repurpose "linux-gcc" job for deprecations
      builtin/pack-redundant: remove subcommand with breaking changes
      remote: announce removal of "branches/" and "remotes/"
 .github/workflows/main.yml             |  6 +----
 .gitlab-ci.yml                         |  6 +----
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 GIT-BUILD-OPTIONS.in                   |  1 +
 Makefile                               |  7 +++++
 builtin/remote.c                       |  2 ++
 ci/lib.sh                              |  5 ----
 ci/run-build-and-tests.sh              |  3 ++-
 contrib/buildsystems/CMakeLists.txt    |  1 +
 git.c                                  |  2 ++
 meson.build                            |  6 +++++
 meson_options.txt                      |  2 ++
 remote.c                               | 26 +++++++++++++++++++
 remote.h                               |  2 ++
 t/t5323-pack-redundant.sh              |  6 +++++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 t/test-lib.sh                          |  4 +++
 21 files changed, 132 insertions(+), 59 deletions(-)
Range-diff versus v3:
1:  c9ab464545 = 1:  b72e562c5a Makefile: wire up build option for deprecated features
2:  992c55543e = 2:  a6c0aa40f0 ci: merge linux-gcc-default into linux-gcc
3:  e9d9721fbf = 3:  c4aa9d092b ci: repurpose "linux-gcc" job for deprecations
4:  2588dff0f8 = 4:  7977a853ef builtin/pack-redundant: remove subcommand with breaking changes
5:  671a527782 ! 5:  c607948f6a remote: announce removal of "branches/" and "remotes/"
    @@ Documentation/BreakingChanges.txt: Cf. <xmqq1rjuz6n3.fsf_-_@gitster.c.googlers.c
     +As our documentation mentions, these directories are not to be found in modern
     +repositories at all and most users aren't even aware of these mechanisms. They
     +have been deprecated for almost 20 years and 14 years respectively, and we are
    -+not aware of any reason why anybody would want to use these mechanisms.
    ++not aware of any active users that have complained about this deprecation.
     +Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
     +may cause confusion as "branches" are almost exclusively used in the context of
     +references.
    @@ remote.c: static void add_instead_of(struct rewrite *rewrite, const char *instea
      static const char *skip_spaces(const char *s)
      {
      	while (isspace(*s))
    +@@ remote.c: static const char *skip_spaces(const char *s)
    + 	return s;
    + }
    + 
    ++static void warn_about_deprecated_remote_type(const char *type,
    ++					      const struct remote *remote)
    ++{
    ++	warning(_("reading remote from \"%s/%s\", which is nominated for removal.\n"
    ++		  "\n"
    ++		  "If you still use the \"remotes/\" directory it is recommended to\n"
    ++		  "migrate to config-based remotes:\n"
    ++		  "\n"
    ++		  "\tgit remote rename %s %s\n"
    ++		  "\n"
    ++		  "If you cannot, please let us know you still use it by sending an\n"
    ++		  "e-mail to <git@vger.kernel.org>."),
    ++		type, remote->name, remote->name, remote->name);
    ++}
    ++
    + static void read_remotes_file(struct remote_state *remote_state,
    + 			      struct remote *remote)
    + {
     @@ remote.c: static void read_remotes_file(struct remote_state *remote_state,
      
      	if (!f)
      		return;
     +
    -+	warning(_("Reading remote from \"remotes/%s\", which is nominated\n"
    -+		  "for removal. If you still use the \"remotes/\" directory\n"
    -+		  "it is recommended to migrate to config-based remotes. If\n"
    -+		  "you cannot, please let us know you still use it by sending\n"
    -+		  "an e-mail to <git@vger.kernel.org>."), remote->name);
    ++	warn_about_deprecated_remote_type("remotes", remote);
     +
      	remote->configured_in_repo = 1;
      	remote->origin = REMOTE_REMOTES;
    @@ remote.c: static void read_branches_file(struct remote_state *remote_state,
      	if (!f)
      		return;
      
    -+	warning(_("Reading remote from \"branches/%s\", which is nominated\n"
    -+		  "for removal. If you still use the \"branches/\" directory\n"
    -+		  "it is recommended to migrate to config-based remotes. If\n"
    -+		  "you cannot, please let us know you still use it by sending\n"
    -+		  "an e-mail to <git@vger.kernel.org>."), remote->name);
    ++	warn_about_deprecated_remote_type("branches", remote);
     +
      	strbuf_getline_lf(&buf, f);
      	fclose(f);

--- base-commit: 713ec79a9091cec60b110d605b418904759982ab change-id: 20241205-pks-remote-branches-deprecation-037a4389a377

Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 1/5] Makefile: wire up build option for deprecated features

With 57ec9254eb (docs: introduce document to announce breaking changes, 2024-06-14), we have introduced a new document that tracks upcoming breaking changes in the Git project. In 2454970930 (BreakingChanges: early adopter option, 2024-10-11) we have amended the document a bit to mention that any introduced breaking changes must be accompanied by logic that allows us to enable the breaking change at compile-time. While we already have two breaking changes lined up, neither of them has such a switch because they predate those instructions.

Introduce the proposed `WITH_BREAKING_CHANGES` preprocessor macro and wire it up with both our Makefiles and Meson. This does not yet wire up the build flag for existing deprecations.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 GIT-BUILD-OPTIONS.in                | 1 +
 Makefile                            | 5 +++++
 contrib/buildsystems/CMakeLists.txt | 1 +
 meson.build                         | 6 ++++++
 meson_options.txt                   | 2 ++
 t/test-lib.sh                       | 4 ++++
 6 files changed, 19 insertions(+)
Show changes to 6 files +19 −0

GIT-BUILD-OPTIONS.in, Makefile, contrib/buildsystems/CMakeLists.txt, meson.build, meson_options.txt, t/test-lib.sh

diff --git a/GIT-BUILD-OPTIONS.in b/GIT-BUILD-OPTIONS.in
index f651116102..f1d0ecf123 100644
--- a/GIT-BUILD-OPTIONS.in
+++ b/GIT-BUILD-OPTIONS.in
@@ -45,3 +45,4 @@ GITWEBDIR=@GITWEBDIR@
 USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
 LOCALEDIR=@LOCALEDIR@
 BROKEN_PATH_FIX=@BROKEN_PATH_FIX@
+WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@
diff --git a/Makefile b/Makefile
index 06f01149ec..dc3c980aa7 100644
--- a/Makefile
+++ b/Makefile
@@ -2230,6 +2230,10 @@ ifdef FSMONITOR_OS_SETTINGS
 	COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
 endif
 
+ifdef WITH_BREAKING_CHANGES
+	BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
+endif
+
 ifeq ($(TCLTK_PATH),)
 NO_TCLTK = NoThanks
 endif
@@ -3187,6 +3191,7 @@ GIT-BUILD-OPTIONS: FORCE
 		-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
 		-e "s|@LOCALEDIR@|\'$(localedir_SQ)\'|" \
 		-e "s!@BROKEN_PATH_FIX@!\'$(BROKEN_PATH_FIX)\'!" \
+		-e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
 		GIT-BUILD-OPTIONS.in >$@+
 	@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi
 	@if cmp $@+ $@ >/dev/null 2>&1; then $(RM) $@+; else mv $@+ $@; fi
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 49904ca8a9..63d0088928 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -1198,6 +1198,7 @@ string(REPLACE "@GITWEBDIR@" "'${GITWEBDIR}'" git_build_options "${git_build_opt
 string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
 string(REPLACE "@LOCALEDIR@" "'${LOCALEDIR}'" git_build_options "${git_build_options}")
 string(REPLACE "@BROKEN_PATH_FIX@" "" git_build_options "${git_build_options}")
+string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
 if(USE_VCPKG)
 	string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")
 endif()
diff --git a/meson.build b/meson.build
index 0dccebcdf1..316cd93264 100644
--- a/meson.build
+++ b/meson.build
@@ -644,6 +644,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
 build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
 build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
 
+if get_option('breaking_changes')
+  build_options_config.set('WITH_BREAKING_CHANGES', 'YesPlease')
+else
+  build_options_config.set('WITH_BREAKING_CHANGES', '')
+endif
+
 if get_option('sane_tool_path') != ''
   build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
 else
diff --git a/meson_options.txt b/meson_options.txt
index 32a72139ba..800e518d95 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -43,6 +43,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
   description: 'The backend used for hashing objects with the SHA256 object format')
 
 # Build tweaks.
+option('breaking_changes', type: 'boolean', value: false,
+  description: 'Enable upcoming breaking changes.')
 option('macos_use_homebrew_gettext', type: 'boolean', value: true,
   description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
 
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62dfcc4aaf..6e423f655d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1864,6 +1864,10 @@ test_lazy_prereq CURL '
 	curl --version
 '
 
+test_lazy_prereq WITHOUT_BREAKING_CHANGES '
+	test -z "$WITH_BREAKING_CHANGES"
+'
+
 # SHA1 is a test if the hash algorithm in use is SHA-1.  This is both for tests
 # which will not work with other hash algorithms and tests that work but don't
 # test anything meaningful (e.g. special values which cause short collisions).
-- 
2.48.1.321.gbf1f004a4a.dirty
Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 2/5] ci: merge linux-gcc-default into linux-gcc

The "linux-gcc-default" job is mostly doing the same as the "linux-gcc" job, except for a couple of minor differences:

  - We use an explicit GCC version instead of the default version
    provided by the distribution. We have other jobs that test with
    "gcc-8", making this distinction pointless.
  - We don't set up the Python version explicitly, and instead use the
    default Python version. Python 2 has been end-of-life for quite a
    while now though, making this distinction less interesting.
  - We set up the default branch name to be "main" in "linux-gcc". We
    have other testcases that don't and also some that explicitly use
    "master".
  - We use "ubuntu:20.04" in one job and "ubuntu:latest" in another. We
    already have a couple other jobs testing these respectively.
So overall, the job does not add much to our test coverage.

Drop the "linux-gcc-default" job and adapt "linux-gcc" to start using the default GCC compiler, effectively merging those two jobs into one.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 4 ----
 .gitlab-ci.yml             | 4 ----
 ci/lib.sh                  | 5 -----
 3 files changed, 13 deletions(-)
Show changes to 3 files +0 −13

.github/workflows/main.yml, .gitlab-ci.yml, ci/lib.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 808ddc19b8..32d35d2257 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -271,7 +271,6 @@ jobs:
             pool: ubuntu-latest
           - jobname: linux-gcc
             cc: gcc
-            cc_package: gcc-8
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
             cc: gcc
@@ -286,9 +285,6 @@ jobs:
           - jobname: osx-gcc
             cc: gcc-13
             pool: macos-13
-          - jobname: linux-gcc-default
-            cc: gcc
-            pool: ubuntu-latest
           - jobname: linux-leaks
             cc: gcc
             pool: ubuntu-latest
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index a1bc92893f..b86bb0bdb3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -46,14 +46,10 @@ test:linux:
       - jobname: linux-gcc
         image: ubuntu:20.04
         CC: gcc
-        CC_PACKAGE: gcc-8
       - jobname: linux-TEST-vars
         image: ubuntu:20.04
         CC: gcc
         CC_PACKAGE: gcc-8
-      - jobname: linux-gcc-default
-        image: ubuntu:latest
-        CC: gcc
       - jobname: linux-leaks
         image: ubuntu:latest
         CC: gcc
diff --git a/ci/lib.sh b/ci/lib.sh
index 930f98d722..e67c481d4f 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -328,11 +328,6 @@ export SKIP_DASHED_BUILT_INS=YesPlease
 
 case "$distro" in
 ubuntu-*)
-	if test "$jobname" = "linux-gcc-default"
-	then
-		break
-	fi
-
 	# Python 2 is end of life, and Ubuntu 23.04 and newer don't actually
 	# have it anymore. We thus only test with Python 2 on older LTS
 	# releases.
-- 
2.48.1.321.gbf1f004a4a.dirty
Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 3/5] ci: repurpose "linux-gcc" job for deprecations

The "linux-gcc" job isn't all that interesting by itself and can be considered more or less the "standard" job: it is running with a reasonably up-to-date image and uses GCC as a compiler, both of which we already cover in other jobs.

There is one exception though: we change the default branch to be "main" instead of "master", so it is forging ahead a bit into the future to make sure that this change does not cause havoc. So let's expand on this a bit and also add the new "WITH_BREAKING_CHANGES" flag to the mix.

Rename the job to "linux-breaking-changes" accordingly.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 .github/workflows/main.yml | 2 +-
 .gitlab-ci.yml             | 2 +-
 ci/run-build-and-tests.sh  | 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)
Show changes to 3 files +4 −3

.github/workflows/main.yml, .gitlab-ci.yml, ci/run-build-and-tests.sh

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 32d35d2257..46b96fb96c 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -269,7 +269,7 @@ jobs:
           - jobname: linux-reftable
             cc: clang
             pool: ubuntu-latest
-          - jobname: linux-gcc
+          - jobname: linux-breaking-changes
             cc: gcc
             pool: ubuntu-20.04
           - jobname: linux-TEST-vars
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b86bb0bdb3..492e5d9082 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -43,7 +43,7 @@ test:linux:
       - jobname: linux-reftable
         image: ubuntu:latest
         CC: clang
-      - jobname: linux-gcc
+      - jobname: linux-breaking-changes
         image: ubuntu:20.04
         CC: gcc
       - jobname: linux-TEST-vars
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 2e28d02b20..2ccd812fb4 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -13,8 +13,9 @@ esac
 run_tests=t
 
 case "$jobname" in
-linux-gcc)
+linux-breaking-changes)
 	export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+	export WITH_BREAKING_CHANGES=YesPlease
 	;;
 linux-TEST-vars)
 	export GIT_TEST_SPLIT_INDEX=yes
-- 
2.48.1.321.gbf1f004a4a.dirty
Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 4/5] builtin/pack-redundant: remove subcommand with breaking changes

The git-pack-redundant(1) subcommand has been announced for removal with 53a92c9552 (Documentation/BreakingChanges: announce removal of git-pack-redundant(1), 2024-09-02). Stop compiling the subcommand in case the `WITH_BREAKING_CHANGES` build flag is set.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Makefile                  | 2 ++
 git.c                     | 2 ++
 t/t5323-pack-redundant.sh | 6 ++++++
 3 files changed, 10 insertions(+)
Show changes to 3 files +10 −0

Makefile, git.c, t/t5323-pack-redundant.sh

diff --git a/Makefile b/Makefile
index dc3c980aa7..e6b0d85980 100644
--- a/Makefile
+++ b/Makefile
@@ -1278,7 +1278,9 @@ BUILTIN_OBJS += builtin/mv.o
 BUILTIN_OBJS += builtin/name-rev.o
 BUILTIN_OBJS += builtin/notes.o
 BUILTIN_OBJS += builtin/pack-objects.o
+ifndef WITH_BREAKING_CHANGES
 BUILTIN_OBJS += builtin/pack-redundant.o
+endif
 BUILTIN_OBJS += builtin/pack-refs.o
 BUILTIN_OBJS += builtin/patch-id.o
 BUILTIN_OBJS += builtin/prune-packed.o
diff --git a/git.c b/git.c
index 46b3c740c5..a13c32bcdc 100644
--- a/git.c
+++ b/git.c
@@ -589,7 +589,9 @@ static struct cmd_struct commands[] = {
 	{ "name-rev", cmd_name_rev, RUN_SETUP },
 	{ "notes", cmd_notes, RUN_SETUP },
 	{ "pack-objects", cmd_pack_objects, RUN_SETUP },
+#ifndef WITH_BREAKING_CHANGES
 	{ "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT },
+#endif
 	{ "pack-refs", cmd_pack_refs, RUN_SETUP },
 	{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
 	{ "pickaxe", cmd_blame, RUN_SETUP },
diff --git a/t/t5323-pack-redundant.sh b/t/t5323-pack-redundant.sh
index 8dbbcc5e51..688cd9706c 100755
--- a/t/t5323-pack-redundant.sh
+++ b/t/t5323-pack-redundant.sh
@@ -36,6 +36,12 @@ relationship between packs and objects is as follows:
 
 . ./test-lib.sh
 
+if ! test_have_prereq WITHOUT_BREAKING_CHANGES
+then
+	skip_all='skipping git-pack-redundant tests; built with breaking changes'
+	test_done
+fi
+
 main_repo=main.git
 shared_repo=shared.git
 
-- 
2.48.1.321.gbf1f004a4a.dirty
Patrick Steinhardt· Jan 22, 2025, 11:31 UTC · re: Patrick Steinhardt · lore

[PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

Back when Git was in its infancy, remotes were configured via separate files in "branches/" (back in 2005). This mechanism was replaced later that year with the "remotes/" directory. Both mechanisms have eventually been replaced by config-based remotes, and it is very unlikely that anybody still uses these directories to configure their remotes.

Both of these directories have been marked as deprecated, one in 2005 and the other one in 2011. Follow through with the deprecation and finally announce the removal of these features in Git 3.0.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 Documentation/BreakingChanges.txt      | 25 ++++++++++++++++++
 Documentation/gitrepository-layout.txt |  7 +++--
 builtin/remote.c                       |  2 ++
 remote.c                               | 26 +++++++++++++++++++
 remote.h                               |  2 ++
 t/t5505-remote.sh                      |  6 ++---
 t/t5510-fetch.sh                       | 13 ++++------
 t/t5515-fetch-merge-logic.sh           | 47 ++++++++++++++++++----------------
 t/t5516-fetch-push.sh                  | 14 +++++-----
 9 files changed, 99 insertions(+), 43 deletions(-)
Show changes to 9 files +99 −43

Documentation/BreakingChanges.txt, Documentation/gitrepository-layout.txt, builtin/remote.c, remote.c, remote.h, t/t5505-remote.sh, t/t5510-fetch.sh, t/t5515-fetch-merge-logic.sh, t/t5516-fetch-push.sh

diff --git a/Documentation/BreakingChanges.txt b/Documentation/BreakingChanges.txt
index 27acff86db..7c388e56c8 100644
--- a/Documentation/BreakingChanges.txt
+++ b/Documentation/BreakingChanges.txt
@@ -154,6 +154,31 @@ Cf. <xmqq1rjuz6n3.fsf_-_@gitster.c.googlers.com>,
     <CAKvOHKAFXQwt4D8yUCCkf_TQL79mYaJ=KAKhtpDNTvHJFuX1NA@mail.gmail.com>,
     <20230323204047.GA9290@coredump.intra.peff.net>,
 
+* Support for storing shorthands for remote URLs in "$GIT_COMMON_DIR/branches/"
+  and "$GIT_COMMON_DIR/remotes/" has been long superseded by storing remotes in
+  the repository configuration.
++
+The mechanism has originally been introduced in f170e4b39d ([PATCH] fetch/pull:
+short-hand notation for remote repositories., 2005-07-16) and was superseded by
+6687f8fea2 ([PATCH] Use .git/remote/origin, not .git/branches/origin.,
+2005-08-20), where we switched from ".git/branches/" to ".git/remotes/". That
+commit already mentions an upcoming deprecation of the ".git/branches/"
+directory, and starting with a1d4aa7424 (Add repository-layout document.,
+2005-09-01) we have also marked this layout as deprecated. Eventually we also
+started to migrate away from ".git/remotes/" in favor of config-based remotes,
+and we have marked the directory as legacy in 3d3d282146 (Documentation:
+Grammar correction, wording fixes and cleanup, 2011-08-23)
++
+As our documentation mentions, these directories are not to be found in modern
+repositories at all and most users aren't even aware of these mechanisms. They
+have been deprecated for almost 20 years and 14 years respectively, and we are
+not aware of any active users that have complained about this deprecation.
+Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
+may cause confusion as "branches" are almost exclusively used in the context of
+references.
++
+These features will be removed.
+
 == Superseded features that will not be deprecated
 
 Some features have gained newer replacements that aim to improve the design in
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index fa8b51daf0..85911ca8ea 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -153,7 +153,7 @@ config.worktree::
 	linkgit:git-worktree[1]).
 
 branches::
-	A slightly deprecated way to store shorthands to be used
+	A deprecated way to store shorthands to be used
 	to specify a URL to 'git fetch', 'git pull' and 'git push'.
 	A file can be stored as `branches/<name>` and then
 	'name' can be given to these commands in place of
@@ -162,7 +162,8 @@ branches::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/branches" will be used instead.
-
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 hooks::
 	Hooks are customization scripts used by various Git
@@ -238,6 +239,8 @@ remotes::
 	and not likely to be found in modern repositories. This
 	directory is ignored if $GIT_COMMON_DIR is set and
 	"$GIT_COMMON_DIR/remotes" will be used instead.
++
+Git will stop reading remotes from this directory in Git 3.0.
 
 logs::
 	Records of changes made to refs are stored in this directory.
diff --git a/builtin/remote.c b/builtin/remote.c
index 1ad3e70a6b..e565b2b3fe 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -640,10 +640,12 @@ static int migrate_file(struct remote *remote)
 	strbuf_addf(&buf, "remote.%s.fetch", remote->name);
 	for (i = 0; i < remote->fetch.nr; i++)
 		git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (remote->origin == REMOTE_REMOTES)
 		unlink_or_warn(git_path("remotes/%s", remote->name));
 	else if (remote->origin == REMOTE_BRANCHES)
 		unlink_or_warn(git_path("branches/%s", remote->name));
+#endif /* WITH_BREAKING_CHANGES */
 	strbuf_release(&buf);
 
 	return 0;
diff --git a/remote.c b/remote.c
index 10104d11e3..ec69863f11 100644
--- a/remote.c
+++ b/remote.c
@@ -293,6 +293,7 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
 	rewrite->instead_of_nr++;
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static const char *skip_spaces(const char *s)
 {
 	while (isspace(*s))
@@ -300,6 +301,21 @@ static const char *skip_spaces(const char *s)
 	return s;
 }
 
+static void warn_about_deprecated_remote_type(const char *type,
+					      const struct remote *remote)
+{
+	warning(_("reading remote from \"%s/%s\", which is nominated for removal.\n"
+		  "\n"
+		  "If you still use the \"remotes/\" directory it is recommended to\n"
+		  "migrate to config-based remotes:\n"
+		  "\n"
+		  "\tgit remote rename %s %s\n"
+		  "\n"
+		  "If you cannot, please let us know you still use it by sending an\n"
+		  "e-mail to <git@vger.kernel.org>."),
+		type, remote->name, remote->name, remote->name);
+}
+
 static void read_remotes_file(struct remote_state *remote_state,
 			      struct remote *remote)
 {
@@ -308,6 +324,9 @@ static void read_remotes_file(struct remote_state *remote_state,
 
 	if (!f)
 		return;
+
+	warn_about_deprecated_remote_type("remotes", remote);
+
 	remote->configured_in_repo = 1;
 	remote->origin = REMOTE_REMOTES;
 	while (strbuf_getline(&buf, f) != EOF) {
@@ -337,6 +356,8 @@ static void read_branches_file(struct remote_state *remote_state,
 	if (!f)
 		return;
 
+	warn_about_deprecated_remote_type("branches", remote);
+
 	strbuf_getline_lf(&buf, f);
 	fclose(f);
 	strbuf_trim(&buf);
@@ -374,6 +395,7 @@ static void read_branches_file(struct remote_state *remote_state,
 	strbuf_release(&buf);
 	free(to_free);
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static int handle_config(const char *key, const char *value,
 			 const struct config_context *ctx, void *cb)
@@ -572,6 +594,7 @@ static void read_config(struct repository *repo, int early)
 	alias_all_urls(repo->remote_state);
 }
 
+#ifndef WITH_BREAKING_CHANGES
 static int valid_remote_nick(const char *name)
 {
 	if (!name[0] || is_dot_or_dotdot(name))
@@ -583,6 +606,7 @@ static int valid_remote_nick(const char *name)
 			return 0;
 	return 1;
 }
+#endif /* WITH_BREAKING_CHANGES */
 
 static const char *remotes_remote_for_branch(struct remote_state *remote_state,
 					     struct branch *branch,
@@ -725,12 +749,14 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
 				   &name_given);
 
 	ret = make_remote(remote_state, name, 0);
+#ifndef WITH_BREAKING_CHANGES
 	if (valid_remote_nick(name) && have_git_dir()) {
 		if (!valid_remote(ret))
 			read_remotes_file(remote_state, ret);
 		if (!valid_remote(ret))
 			read_branches_file(remote_state, ret);
 	}
+#endif /* WITH_BREAKING_CHANGES */
 	if (name_given && !valid_remote(ret))
 		add_url_alias(remote_state, ret, name);
 	if (!valid_remote(ret))
diff --git a/remote.h b/remote.h
index a7e5c4e07c..45b0c9babb 100644
--- a/remote.h
+++ b/remote.h
@@ -21,8 +21,10 @@ struct transport_ls_refs_options;
 enum {
 	REMOTE_UNCONFIGURED = 0,
 	REMOTE_CONFIG,
+#ifndef WITH_BREAKING_CHANGES
 	REMOTE_REMOTES,
 	REMOTE_BRANCHES
+#endif /* WITH_BREAKING_CHANGES */
 };
 
 struct rewrite {
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 08424e878e..e96ac8c767 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -1007,7 +1007,7 @@ Pull: refs/heads/main:refs/heads/origin
 Pull: refs/heads/next:refs/heads/origin2
 EOF
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/remotes' '
 	git clone one five &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1033,7 +1033,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches' '
 	git clone --template= one six &&
 	origin_url=$(pwd)/one &&
 	(
@@ -1049,7 +1049,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
 	)
 '
 
-test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches (2)' '
 	git clone --template= one seven &&
 	(
 		cd seven &&
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 3b3991ab86..04d8a96367 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -34,14 +34,11 @@ test_expect_success "clone and setup child repos" '
 	git clone . three &&
 	(
 		cd three &&
-		git config branch.main.remote two &&
-		git config branch.main.merge refs/heads/one &&
-		mkdir -p .git/remotes &&
-		cat >.git/remotes/two <<-\EOF
-		URL: ../two/.git/
-		Pull: refs/heads/main:refs/heads/two
-		Pull: refs/heads/one:refs/heads/one
-		EOF
+		git config set remote.two.url ../two/.git/ &&
+		git config set remote.two.fetch refs/heads/main:refs/heads/two &&
+		git config set --append remote.two.fetch refs/heads/one:refs/heads/one &&
+		git config set branch.main.remote two &&
+		git config set branch.main.merge refs/heads/one
 	) &&
 	git clone . bundle &&
 	git clone . seven
diff --git a/t/t5515-fetch-merge-logic.sh b/t/t5515-fetch-merge-logic.sh
index 320d26796d..4e6026c611 100755
--- a/t/t5515-fetch-merge-logic.sh
+++ b/t/t5515-fetch-merge-logic.sh
@@ -104,28 +104,31 @@ test_expect_success setup '
 	git config remote.config-glob.fetch refs/heads/*:refs/remotes/rem/* &&
 	remotes="$remotes config-glob" &&
 
-	mkdir -p .git/remotes &&
-	cat >.git/remotes/remote-explicit <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/main:remotes/rem/main
-	Pull: refs/heads/one:remotes/rem/one
-	Pull: two:remotes/rem/two
-	Pull: refs/heads/three:remotes/rem/three
-	EOF
-	remotes="$remotes remote-explicit" &&
-
-	cat >.git/remotes/remote-glob <<-\EOF &&
-	URL: ../.git/
-	Pull: refs/heads/*:refs/remotes/rem/*
-	EOF
-	remotes="$remotes remote-glob" &&
-
-	mkdir -p .git/branches &&
-	echo "../.git" > .git/branches/branches-default &&
-	remotes="$remotes branches-default" &&
-
-	echo "../.git#one" > .git/branches/branches-one &&
-	remotes="$remotes branches-one" &&
+	if test_have_prereq WITHOUT_BREAKING_CHANGES
+	then
+		mkdir -p .git/remotes &&
+		cat >.git/remotes/remote-explicit <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/main:remotes/rem/main
+		Pull: refs/heads/one:remotes/rem/one
+		Pull: two:remotes/rem/two
+		Pull: refs/heads/three:remotes/rem/three
+		EOF
+		remotes="$remotes remote-explicit" &&
+
+		cat >.git/remotes/remote-glob <<-\EOF &&
+		URL: ../.git/
+		Pull: refs/heads/*:refs/remotes/rem/*
+		EOF
+		remotes="$remotes remote-glob" &&
+
+		mkdir -p .git/branches &&
+		echo "../.git" > .git/branches/branches-default &&
+		remotes="$remotes branches-default" &&
+
+		echo "../.git#one" > .git/branches/branches-one &&
+		remotes="$remotes branches-one"
+	fi &&
 
 	for remote in $remotes ; do
 		git config branch.br-$remote.remote $remote &&
diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh
index 9d693eb57f..e705aedbf4 100755
--- a/t/t5516-fetch-push.sh
+++ b/t/t5516-fetch-push.sh
@@ -975,7 +975,7 @@ test_expect_success 'allow push to HEAD of non-bare repository (config)' '
 	! grep "warning: updating the current branch" stderr
 '
 
-test_expect_success 'fetch with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches' '
 	mk_empty testrepo &&
 	git branch second $the_first_commit &&
 	git checkout second &&
@@ -991,7 +991,7 @@ test_expect_success 'fetch with branches' '
 	git checkout main
 '
 
-test_expect_success 'fetch with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'fetch with branches containing #' '
 	mk_empty testrepo &&
 	mkdir testrepo/.git/branches &&
 	echo "..#second" > testrepo/.git/branches/branch2 &&
@@ -1005,7 +1005,7 @@ test_expect_success 'fetch with branches containing #' '
 	git checkout main
 '
 
-test_expect_success 'push with branches' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches' '
 	mk_empty testrepo &&
 	git checkout second &&
 
@@ -1022,7 +1022,7 @@ test_expect_success 'push with branches' '
 	)
 '
 
-test_expect_success 'push with branches containing #' '
+test_expect_success WITHOUT_BREAKING_CHANGES 'push with branches containing #' '
 	mk_empty testrepo &&
 
 	test_when_finished "rm -rf .git/branches" &&
@@ -1211,18 +1211,16 @@ test_expect_success 'push --porcelain --dry-run rejected' '
 '
 
 test_expect_success 'push --prune' '
-	mk_test testrepo heads/main heads/second heads/foo heads/bar &&
+	mk_test testrepo heads/main heads/foo heads/bar &&
 	git push --prune testrepo : &&
 	check_push_result testrepo $the_commit heads/main &&
-	check_push_result testrepo $the_first_commit heads/second &&
 	! check_push_result testrepo $the_first_commit heads/foo heads/bar
 '
 
 test_expect_success 'push --prune refspec' '
-	mk_test testrepo tmp/main tmp/second tmp/foo tmp/bar &&
+	mk_test testrepo tmp/main tmp/foo tmp/bar &&
 	git push --prune testrepo "refs/heads/*:refs/tmp/*" &&
 	check_push_result testrepo $the_commit tmp/main &&
-	check_push_result testrepo $the_first_commit tmp/second &&
 	! check_push_result testrepo $the_first_commit tmp/foo tmp/bar
 '
 
-- 
2.48.1.321.gbf1f004a4a.dirty
Junio C Hamano· Jan 22, 2025, 20:32 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
> +		  "If you cannot, please let us know you still use it by sending an\n"
> +		  "e-mail to <git@vger.kernel.org>."),
> +		type, remote->name, remote->name, remote->name);
> +}

I do not think we want to receive a piece of e-mail that says they want us to know they still use it. I do not mind seeing one that says WHY they cannot switch, though.

If there is no objection, let me do
	"let us know you still" -> "let us know why you still"
on top.

I like the way this has been made into a helper function, without causing sentence-logo that would have annoyed translators.

Thanks.  Will replace.
Jakub Wilk· Feb 21, 2025, 15:26 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

* Patrick Steinhardt <ps@pks.im>, 2025-01-22 12:31:
>+As our documentation mentions, these directories are not to be found in modern
>+repositories at all and most users aren't even aware of these mechanisms. They

This isn't accurate. The "branches/" directory used to be part of the default template until very recently, so it's found all over the place (although most likely empty).

I'd say: "... these directories are unlikely to be used in modern repositories and ..."

-- 
Jakub Wilk
Junio C Hamano· Feb 21, 2025, 18:30 UTC · re: Jakub Wilk · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

Jakub Wilk <jwilk@jwilk.net> writes:
Show 10 quoted lines
> * Patrick Steinhardt <ps@pks.im>, 2025-01-22 12:31:
>>+As our documentation mentions, these directories are not to be found in modern
>>+repositories at all and most users aren't even aware of these mechanisms. They
>
> This isn't accurate. The "branches/" directory used to be part of the
> default template until very recently, so it's found all over the place
> (although most likely empty).
>
> I'd say: "... these directories are unlikely to be used in modern
> repositories and ..."

That's a very careful reading. Thanks for pointing out the distinction between being found and being used.

Patrick Steinhardt· Feb 25, 2025, 07:58 UTC · re: Junio C Hamano · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

On Fri, Feb 21, 2025 at 10:30:30AM -0800, Junio C Hamano wrote:
Show 15 quoted lines
> Jakub Wilk <jwilk@jwilk.net> writes:
> 
> > * Patrick Steinhardt <ps@pks.im>, 2025-01-22 12:31:
> >>+As our documentation mentions, these directories are not to be found in modern
> >>+repositories at all and most users aren't even aware of these mechanisms. They
> >
> > This isn't accurate. The "branches/" directory used to be part of the
> > default template until very recently, so it's found all over the place
> > (although most likely empty).
> >
> > I'd say: "... these directories are unlikely to be used in modern
> > repositories and ..."
> 
> That's a very careful reading.  Thanks for pointing out the
> distinction between being found and being used.

Indeed. Do you maybe want to send a patch for this? Otherwise I can handle it for you.

Thanks!
Patrick
Junio C Hamano· Feb 25, 2025, 23:45 UTC · re: Patrick Steinhardt · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

Patrick Steinhardt <ps@pks.im> writes:
Show 23 quoted lines
> On Fri, Feb 21, 2025 at 10:30:30AM -0800, Junio C Hamano wrote:
>> Jakub Wilk <jwilk@jwilk.net> writes:
>> 
>> > * Patrick Steinhardt <ps@pks.im>, 2025-01-22 12:31:
>> >>+As our documentation mentions, these directories are not to be found in modern
>> >>+repositories at all and most users aren't even aware of these mechanisms. They
>> >
>> > This isn't accurate. The "branches/" directory used to be part of the
>> > default template until very recently, so it's found all over the place
>> > (although most likely empty).
>> >
>> > I'd say: "... these directories are unlikely to be used in modern
>> > repositories and ..."
>> 
>> That's a very careful reading.  Thanks for pointing out the
>> distinction between being found and being used.
>
> Indeed. Do you maybe want to send a patch for this? Otherwise I can
> handle it for you.
>
> Thanks!
>
> Patrick
--- >8 ---
Subject: BreakingChanges: clarify branches/ and remotes/

As we have created an empty .git/branches/ hierarchy until fairly recently, these directories may be found in modern repositories, but it is highly unlikely that they are being used.

Reported-by: Jakub Wilk <jwilk@jwilk.net>
Acked-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/BreakingChanges.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Show changes to diff +2 −2
diff --git c/Documentation/BreakingChanges.txt w/Documentation/BreakingChanges.txt
index 7c388e56c8..042709a461 100644
--- c/Documentation/BreakingChanges.txt
+++ w/Documentation/BreakingChanges.txt
@@ -169,8 +169,8 @@ started to migrate away from ".git/remotes/" in favor of config-based remotes,
 and we have marked the directory as legacy in 3d3d282146 (Documentation:
 Grammar correction, wording fixes and cleanup, 2011-08-23)
 +
-As our documentation mentions, these directories are not to be found in modern
-repositories at all and most users aren't even aware of these mechanisms. They
+As our documentation mentions, these directories are unlikely to be used in
+modern repositories and most users aren't even aware of these mechanisms. They
 have been deprecated for almost 20 years and 14 years respectively, and we are
 not aware of any active users that have complained about this deprecation.
 Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
Patrick Steinhardt· Feb 26, 2025, 09:21 UTC · re: Junio C Hamano · lore

Re: [PATCH v4 5/5] remote: announce removal of "branches/" and "remotes/"

On Tue, Feb 25, 2025 at 03:45:42PM -0800, Junio C Hamano wrote:
Show 25 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > On Fri, Feb 21, 2025 at 10:30:30AM -0800, Junio C Hamano wrote:
> >> Jakub Wilk <jwilk@jwilk.net> writes:
> >> 
> >> > * Patrick Steinhardt <ps@pks.im>, 2025-01-22 12:31:
> >> >>+As our documentation mentions, these directories are not to be found in modern
> >> >>+repositories at all and most users aren't even aware of these mechanisms. They
> >> >
> >> > This isn't accurate. The "branches/" directory used to be part of the
> >> > default template until very recently, so it's found all over the place
> >> > (although most likely empty).
> >> >
> >> > I'd say: "... these directories are unlikely to be used in modern
> >> > repositories and ..."
> >> 
> >> That's a very careful reading.  Thanks for pointing out the
> >> distinction between being found and being used.
> >
> > Indeed. Do you maybe want to send a patch for this? Otherwise I can
> > handle it for you.
> >
> > Thanks!
> >
> > Patrick

Ah, I didn't mean you, Junio, but Jakub. But anyway, thanks for sending the patch!

Show 29 quoted lines
> --- >8 ---
> Subject: BreakingChanges: clarify branches/ and remotes/
> 
> As we have created an empty .git/branches/ hierarchy until fairly
> recently, these directories may be found in modern repositories, but
> it is highly unlikely that they are being used.
> 
> Reported-by: Jakub Wilk <jwilk@jwilk.net>
> Acked-by: Patrick Steinhardt <ps@pks.im>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
>  Documentation/BreakingChanges.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git c/Documentation/BreakingChanges.txt w/Documentation/BreakingChanges.txt
> index 7c388e56c8..042709a461 100644
> --- c/Documentation/BreakingChanges.txt
> +++ w/Documentation/BreakingChanges.txt
> @@ -169,8 +169,8 @@ started to migrate away from ".git/remotes/" in favor of config-based remotes,
>  and we have marked the directory as legacy in 3d3d282146 (Documentation:
>  Grammar correction, wording fixes and cleanup, 2011-08-23)
>  +
> -As our documentation mentions, these directories are not to be found in modern
> -repositories at all and most users aren't even aware of these mechanisms. They
> +As our documentation mentions, these directories are unlikely to be used in
> +modern repositories and most users aren't even aware of these mechanisms. They
>  have been deprecated for almost 20 years and 14 years respectively, and we are
>  not aware of any active users that have complained about this deprecation.
>  Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
The change looks great to me, thanks!
Patrick

← back to recent threads