Skip to content

Commit 970fcdf

Browse files
committed
Merge branch 'ps/3.0-remote-deprecation' into next
Following the procedure we established to introduce breaking changes for Git 3.0, allow an early opt-in for removing support of $GIT_DIR/branches/ and $GIT_DIR/remotes/ directories to configure remotes. * ps/3.0-remote-deprecation: remote: announce removal of "branches/" and "remotes/" builtin/pack-redundant: remove subcommand with breaking changes ci: repurpose "linux-gcc" job for deprecations ci: merge linux-gcc-default into linux-gcc Makefile: wire up build option for deprecated features
2 parents 97e7607 + 8ccc75c commit 970fcdf

21 files changed

+132
-59
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,8 @@ jobs:
265265
- jobname: linux-reftable
266266
cc: clang
267267
pool: ubuntu-latest
268-
- jobname: linux-gcc
268+
- jobname: linux-breaking-changes
269269
cc: gcc
270-
cc_package: gcc-8
271270
pool: ubuntu-20.04
272271
- jobname: linux-TEST-vars
273272
cc: gcc
@@ -285,9 +284,6 @@ jobs:
285284
- jobname: osx-meson
286285
cc: clang
287286
pool: macos-13
288-
- jobname: linux-gcc-default
289-
cc: gcc
290-
pool: ubuntu-latest
291287
- jobname: linux-leaks
292288
cc: gcc
293289
pool: ubuntu-latest

.gitlab-ci.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@ test:linux:
4545
- jobname: linux-reftable
4646
image: ubuntu:latest
4747
CC: clang
48-
- jobname: linux-gcc
48+
- jobname: linux-breaking-changes
4949
image: ubuntu:20.04
5050
CC: gcc
51-
CC_PACKAGE: gcc-8
5251
- jobname: linux-TEST-vars
5352
image: ubuntu:20.04
5453
CC: gcc
5554
CC_PACKAGE: gcc-8
56-
- jobname: linux-gcc-default
57-
image: ubuntu:latest
58-
CC: gcc
5955
- jobname: linux-leaks
6056
image: ubuntu:latest
6157
CC: gcc

Documentation/BreakingChanges.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,31 @@ Cf. <[email protected]>,
154154
<CAKvOHKAFXQwt4D8yUCCkf_TQL79mYaJ=KAKhtpDNTvHJFuX1NA@mail.gmail.com>,
155155
156156

157+
* Support for storing shorthands for remote URLs in "$GIT_COMMON_DIR/branches/"
158+
and "$GIT_COMMON_DIR/remotes/" has been long superseded by storing remotes in
159+
the repository configuration.
160+
+
161+
The mechanism has originally been introduced in f170e4b39d ([PATCH] fetch/pull:
162+
short-hand notation for remote repositories., 2005-07-16) and was superseded by
163+
6687f8fea2 ([PATCH] Use .git/remote/origin, not .git/branches/origin.,
164+
2005-08-20), where we switched from ".git/branches/" to ".git/remotes/". That
165+
commit already mentions an upcoming deprecation of the ".git/branches/"
166+
directory, and starting with a1d4aa7424 (Add repository-layout document.,
167+
2005-09-01) we have also marked this layout as deprecated. Eventually we also
168+
started to migrate away from ".git/remotes/" in favor of config-based remotes,
169+
and we have marked the directory as legacy in 3d3d282146 (Documentation:
170+
Grammar correction, wording fixes and cleanup, 2011-08-23)
171+
+
172+
As our documentation mentions, these directories are not to be found in modern
173+
repositories at all and most users aren't even aware of these mechanisms. They
174+
have been deprecated for almost 20 years and 14 years respectively, and we are
175+
not aware of any active users that have complained about this deprecation.
176+
Furthermore, the ".git/branches/" directory is nowadays misleadingly named and
177+
may cause confusion as "branches" are almost exclusively used in the context of
178+
references.
179+
+
180+
These features will be removed.
181+
157182
== Superseded features that will not be deprecated
158183

159184
Some features have gained newer replacements that aim to improve the design in

Documentation/gitrepository-layout.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ config.worktree::
153153
linkgit:git-worktree[1]).
154154

155155
branches::
156-
A slightly deprecated way to store shorthands to be used
156+
A deprecated way to store shorthands to be used
157157
to specify a URL to 'git fetch', 'git pull' and 'git push'.
158158
A file can be stored as `branches/<name>` and then
159159
'name' can be given to these commands in place of
@@ -162,7 +162,8 @@ branches::
162162
and not likely to be found in modern repositories. This
163163
directory is ignored if $GIT_COMMON_DIR is set and
164164
"$GIT_COMMON_DIR/branches" will be used instead.
165-
165+
+
166+
Git will stop reading remotes from this directory in Git 3.0.
166167

167168
hooks::
168169
Hooks are customization scripts used by various Git
@@ -238,6 +239,8 @@ remotes::
238239
and not likely to be found in modern repositories. This
239240
directory is ignored if $GIT_COMMON_DIR is set and
240241
"$GIT_COMMON_DIR/remotes" will be used instead.
242+
+
243+
Git will stop reading remotes from this directory in Git 3.0.
241244

242245
logs::
243246
Records of changes made to refs are stored in this directory.

GIT-BUILD-OPTIONS.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ TEST_OUTPUT_DIRECTORY=@TEST_OUTPUT_DIRECTORY@
4545
TEST_SHELL_PATH=@TEST_SHELL_PATH@
4646
USE_GETTEXT_SCHEME=@USE_GETTEXT_SCHEME@
4747
USE_LIBPCRE2=@USE_LIBPCRE2@
48+
WITH_BREAKING_CHANGES=@WITH_BREAKING_CHANGES@
4849
X=@X@

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,9 @@ BUILTIN_OBJS += builtin/mv.o
12731273
BUILTIN_OBJS += builtin/name-rev.o
12741274
BUILTIN_OBJS += builtin/notes.o
12751275
BUILTIN_OBJS += builtin/pack-objects.o
1276+
ifndef WITH_BREAKING_CHANGES
12761277
BUILTIN_OBJS += builtin/pack-redundant.o
1278+
endif
12771279
BUILTIN_OBJS += builtin/pack-refs.o
12781280
BUILTIN_OBJS += builtin/patch-id.o
12791281
BUILTIN_OBJS += builtin/prune-packed.o
@@ -2236,6 +2238,10 @@ ifdef FSMONITOR_OS_SETTINGS
22362238
COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
22372239
endif
22382240

2241+
ifdef WITH_BREAKING_CHANGES
2242+
BASIC_CFLAGS += -DWITH_BREAKING_CHANGES
2243+
endif
2244+
22392245
ifeq ($(TCLTK_PATH),)
22402246
NO_TCLTK = NoThanks
22412247
endif
@@ -3194,6 +3200,7 @@ GIT-BUILD-OPTIONS: FORCE
31943200
-e "s|@TEST_SHELL_PATH@|\'$(TEST_SHELL_PATH_SQ)\'|" \
31953201
-e "s|@USE_GETTEXT_SCHEME@|\'$(USE_GETTEXT_SCHEME)\'|" \
31963202
-e "s|@USE_LIBPCRE2@|\'$(USE_LIBPCRE2)\'|" \
3203+
-e "s|@WITH_BREAKING_CHANGES@|\'$(WITH_BREAKING_CHANGES)\'|" \
31973204
-e "s|@X@|\'$(X)\'|" \
31983205
GIT-BUILD-OPTIONS.in >$@+
31993206
@if grep -q '^[A-Z][A-Z_]*=@.*@$$' $@+; then echo "Unsubstituted build options in $@" >&2 && exit 1; fi

builtin/remote.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,12 @@ static int migrate_file(struct remote *remote)
642642
strbuf_addf(&buf, "remote.%s.fetch", remote->name);
643643
for (i = 0; i < remote->fetch.nr; i++)
644644
git_config_set_multivar(buf.buf, remote->fetch.items[i].raw, "^$", 0);
645+
#ifndef WITH_BREAKING_CHANGES
645646
if (remote->origin == REMOTE_REMOTES)
646647
unlink_or_warn(git_path("remotes/%s", remote->name));
647648
else if (remote->origin == REMOTE_BRANCHES)
648649
unlink_or_warn(git_path("branches/%s", remote->name));
650+
#endif /* WITH_BREAKING_CHANGES */
649651
strbuf_release(&buf);
650652

651653
return 0;

ci/lib.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,6 @@ export SKIP_DASHED_BUILT_INS=YesPlease
329329

330330
case "$distro" in
331331
ubuntu-*)
332-
if test "$jobname" = "linux-gcc-default"
333-
then
334-
break
335-
fi
336-
337332
# Python 2 is end of life, and Ubuntu 23.04 and newer don't actually
338333
# have it anymore. We thus only test with Python 2 on older LTS
339334
# releases.

ci/run-build-and-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ esac
1313
run_tests=t
1414

1515
case "$jobname" in
16-
linux-gcc)
16+
linux-breaking-changes)
1717
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
18+
export WITH_BREAKING_CHANGES=YesPlease
1819
;;
1920
linux-TEST-vars)
2021
export OPENSSL_SHA1_UNSAFE=YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,7 @@ string(REPLACE "@TEST_OUTPUT_DIRECTORY@" "" git_build_options "${git_build_optio
12051205
string(REPLACE "@TEST_SHELL_PATH@" "'${TEST_SHELL_PATH}'" git_build_options "${git_build_options}")
12061206
string(REPLACE "@USE_GETTEXT_SCHEME@" "" git_build_options "${git_build_options}")
12071207
string(REPLACE "@USE_LIBPCRE2@" "" git_build_options "${git_build_options}")
1208+
string(REPLACE "@WITH_BREAKING_CHANGES@" "" git_build_options "${git_build_options}")
12081209
string(REPLACE "@X@" "${EXE_EXTENSION}" git_build_options "${git_build_options}")
12091210
if(USE_VCPKG)
12101211
string(APPEND git_build_options "PATH=\"$PATH:$TEST_DIRECTORY/../compat/vcbuild/vcpkg/installed/x64-windows/bin\"\n")

git.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,9 @@ static struct cmd_struct commands[] = {
587587
{ "name-rev", cmd_name_rev, RUN_SETUP },
588588
{ "notes", cmd_notes, RUN_SETUP },
589589
{ "pack-objects", cmd_pack_objects, RUN_SETUP },
590+
#ifndef WITH_BREAKING_CHANGES
590591
{ "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT },
592+
#endif
591593
{ "pack-refs", cmd_pack_refs, RUN_SETUP },
592594
{ "patch-id", cmd_patch_id, RUN_SETUP_GENTLY | NO_PARSEOPT },
593595
{ "pickaxe", cmd_blame, RUN_SETUP },

meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,12 @@ build_options_config.set('GIT_TEST_UTF8_LOCALE', '')
655655
build_options_config.set_quoted('LOCALEDIR', fs.as_posix(get_option('prefix') / get_option('localedir')))
656656
build_options_config.set('GITWEBDIR', fs.as_posix(get_option('prefix') / get_option('datadir') / 'gitweb'))
657657

658+
if get_option('breaking_changes')
659+
build_options_config.set('WITH_BREAKING_CHANGES', 'YesPlease')
660+
else
661+
build_options_config.set('WITH_BREAKING_CHANGES', '')
662+
endif
663+
658664
if get_option('sane_tool_path') != ''
659665
build_options_config.set_quoted('BROKEN_PATH_FIX', 's|^\# @BROKEN_PATH_FIX@$|git_broken_path_fix "' + get_option('sane_tool_path') + '"|')
660666
else

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ option('sha256_backend', type: 'combo', choices: ['openssl', 'nettle', 'gcrypt',
5959
description: 'The backend used for hashing objects with the SHA256 object format.')
6060

6161
# Build tweaks.
62+
option('breaking_changes', type: 'boolean', value: false,
63+
description: 'Enable upcoming breaking changes.')
6264
option('macos_use_homebrew_gettext', type: 'boolean', value: true,
6365
description: 'Use gettext from Homebrew instead of the slightly-broken system-provided one.')
6466

remote.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,29 @@ static void add_instead_of(struct rewrite *rewrite, const char *instead_of)
294294
rewrite->instead_of_nr++;
295295
}
296296

297+
#ifndef WITH_BREAKING_CHANGES
297298
static const char *skip_spaces(const char *s)
298299
{
299300
while (isspace(*s))
300301
s++;
301302
return s;
302303
}
303304

305+
static void warn_about_deprecated_remote_type(const char *type,
306+
const struct remote *remote)
307+
{
308+
warning(_("reading remote from \"%s/%s\", which is nominated for removal.\n"
309+
"\n"
310+
"If you still use the \"remotes/\" directory it is recommended to\n"
311+
"migrate to config-based remotes:\n"
312+
"\n"
313+
"\tgit remote rename %s %s\n"
314+
"\n"
315+
"If you cannot, please let us know why you still need to use it by\n"
316+
"sending an e-mail to <[email protected]>."),
317+
type, remote->name, remote->name, remote->name);
318+
}
319+
304320
static void read_remotes_file(struct remote_state *remote_state,
305321
struct remote *remote)
306322
{
@@ -309,6 +325,9 @@ static void read_remotes_file(struct remote_state *remote_state,
309325

310326
if (!f)
311327
return;
328+
329+
warn_about_deprecated_remote_type("remotes", remote);
330+
312331
remote->configured_in_repo = 1;
313332
remote->origin = REMOTE_REMOTES;
314333
while (strbuf_getline(&buf, f) != EOF) {
@@ -338,6 +357,8 @@ static void read_branches_file(struct remote_state *remote_state,
338357
if (!f)
339358
return;
340359

360+
warn_about_deprecated_remote_type("branches", remote);
361+
341362
strbuf_getline_lf(&buf, f);
342363
fclose(f);
343364
strbuf_trim(&buf);
@@ -375,6 +396,7 @@ static void read_branches_file(struct remote_state *remote_state,
375396
strbuf_release(&buf);
376397
free(to_free);
377398
}
399+
#endif /* WITH_BREAKING_CHANGES */
378400

379401
static int handle_config(const char *key, const char *value,
380402
const struct config_context *ctx, void *cb)
@@ -591,6 +613,7 @@ static void read_config(struct repository *repo, int early)
591613
alias_all_urls(repo->remote_state);
592614
}
593615

616+
#ifndef WITH_BREAKING_CHANGES
594617
static int valid_remote_nick(const char *name)
595618
{
596619
if (!name[0] || is_dot_or_dotdot(name))
@@ -602,6 +625,7 @@ static int valid_remote_nick(const char *name)
602625
return 0;
603626
return 1;
604627
}
628+
#endif /* WITH_BREAKING_CHANGES */
605629

606630
static const char *remotes_remote_for_branch(struct remote_state *remote_state,
607631
struct branch *branch,
@@ -744,12 +768,14 @@ remotes_remote_get_1(struct remote_state *remote_state, const char *name,
744768
&name_given);
745769

746770
ret = make_remote(remote_state, name, 0);
771+
#ifndef WITH_BREAKING_CHANGES
747772
if (valid_remote_nick(name) && have_git_dir()) {
748773
if (!valid_remote(ret))
749774
read_remotes_file(remote_state, ret);
750775
if (!valid_remote(ret))
751776
read_branches_file(remote_state, ret);
752777
}
778+
#endif /* WITH_BREAKING_CHANGES */
753779
if (name_given && !valid_remote(ret))
754780
add_url_alias(remote_state, ret, name);
755781
if (!valid_remote(ret))

remote.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ struct transport_ls_refs_options;
2121
enum {
2222
REMOTE_UNCONFIGURED = 0,
2323
REMOTE_CONFIG,
24+
#ifndef WITH_BREAKING_CHANGES
2425
REMOTE_REMOTES,
2526
REMOTE_BRANCHES
27+
#endif /* WITH_BREAKING_CHANGES */
2628
};
2729

2830
struct rewrite {

t/t5323-pack-redundant.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ relationship between packs and objects is as follows:
3636

3737
. ./test-lib.sh
3838

39+
if ! test_have_prereq WITHOUT_BREAKING_CHANGES
40+
then
41+
skip_all='skipping git-pack-redundant tests; built with breaking changes'
42+
test_done
43+
fi
44+
3945
main_repo=main.git
4046
shared_repo=shared.git
4147

t/t5505-remote.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ Pull: refs/heads/main:refs/heads/origin
11131113
Pull: refs/heads/next:refs/heads/origin2
11141114
EOF
11151115

1116-
test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
1116+
test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/remotes' '
11171117
git clone one five &&
11181118
origin_url=$(pwd)/one &&
11191119
(
@@ -1139,7 +1139,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/remotes' '
11391139
)
11401140
'
11411141

1142-
test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
1142+
test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches' '
11431143
git clone --template= one six &&
11441144
origin_url=$(pwd)/one &&
11451145
(
@@ -1155,7 +1155,7 @@ test_expect_success 'migrate a remote from named file in $GIT_DIR/branches' '
11551155
)
11561156
'
11571157

1158-
test_expect_success 'migrate a remote from named file in $GIT_DIR/branches (2)' '
1158+
test_expect_success WITHOUT_BREAKING_CHANGES 'migrate a remote from named file in $GIT_DIR/branches (2)' '
11591159
git clone --template= one seven &&
11601160
(
11611161
cd seven &&

t/t5510-fetch.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ test_expect_success "clone and setup child repos" '
3434
git clone . three &&
3535
(
3636
cd three &&
37-
git config branch.main.remote two &&
38-
git config branch.main.merge refs/heads/one &&
39-
mkdir -p .git/remotes &&
40-
cat >.git/remotes/two <<-\EOF
41-
URL: ../two/.git/
42-
Pull: refs/heads/main:refs/heads/two
43-
Pull: refs/heads/one:refs/heads/one
44-
EOF
37+
git config set remote.two.url ../two/.git/ &&
38+
git config set remote.two.fetch refs/heads/main:refs/heads/two &&
39+
git config set --append remote.two.fetch refs/heads/one:refs/heads/one &&
40+
git config set branch.main.remote two &&
41+
git config set branch.main.merge refs/heads/one
4542
) &&
4643
git clone . bundle &&
4744
git clone . seven

0 commit comments

Comments
 (0)