Skip to content

Commit 48d0b65

Browse files
committed
Merge branch 'ps/symlink-symref-deprecation'
"Symlink symref" has been added to the list of things that will disappear at Git 3.0 boundary. * ps/symlink-symref-deprecation: refs/files: deprecate writing symrefs as symbolic links
2 parents 923436e + f570bd9 commit 48d0b65

File tree

4 files changed

+63
-5
lines changed

4 files changed

+63
-5
lines changed

Documentation/BreakingChanges.adoc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,26 @@ The command will be removed.
295295
+
296296
cf. <xmqqa59i45wc.fsf@gitster.g>
297297

298+
* Support for `core.preferSymlinkRefs=true` has been deprecated and will be
299+
removed in Git 3.0. Writing symbolic refs as symbolic links will be phased
300+
out in favor of using plain files using the textual representation of
301+
symbolic refs.
302+
+
303+
Symbolic references were initially always stored as a symbolic link. This was
304+
changed in 9b143c6e15 (Teach update-ref about a symbolic ref stored in a
305+
textfile., 2005-09-25), where a new textual symref format was introduced to
306+
store those symbolic refs in a plain file. In 9f0bb90d16
307+
(core.prefersymlinkrefs: use symlinks for .git/HEAD, 2006-05-02), the Git
308+
project switched the default to use the textual symrefs in favor of symbolic
309+
links.
310+
+
311+
The migration away from symbolic links has happened almost 20 years ago by now,
312+
and there is no known reason why one should prefer them nowadays. Furthermore,
313+
symbolic links are not supported on some platforms.
314+
+
315+
Note that only the writing side for such symbolic links is deprecated. Reading
316+
such symbolic links is still supported for now.
317+
298318
== Superseded features that will not be deprecated
299319

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

Documentation/config/core.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ core.preferSymlinkRefs::
290290
and other symbolic reference files, use symbolic links.
291291
This is sometimes needed to work with old scripts that
292292
expect HEAD to be a symbolic link.
293+
+
294+
This configuration is deprecated and will be removed in Git 3.0. Symbolic refs
295+
will always be written as textual symrefs.
293296

294297
core.alternateRefsCommand::
295298
When advertising tips of available history from an alternate, use the shell to

refs/files-backend.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,20 +2113,35 @@ static int commit_ref_update(struct files_ref_store *refs,
21132113
return 0;
21142114
}
21152115

2116-
#ifdef NO_SYMLINK_HEAD
2116+
#if defined(NO_SYMLINK_HEAD) || defined(WITH_BREAKING_CHANGES)
21172117
#define create_ref_symlink(a, b) (-1)
21182118
#else
21192119
static int create_ref_symlink(struct ref_lock *lock, const char *target)
21202120
{
2121+
static int warn_once = 1;
2122+
char *ref_path;
21212123
int ret = -1;
21222124

2123-
char *ref_path = get_locked_file_path(&lock->lk);
2125+
ref_path = get_locked_file_path(&lock->lk);
21242126
unlink(ref_path);
21252127
ret = symlink(target, ref_path);
21262128
free(ref_path);
21272129

21282130
if (ret)
21292131
fprintf(stderr, "no symlink - falling back to symbolic ref\n");
2132+
2133+
if (warn_once)
2134+
warning(_("'core.preferSymlinkRefs=true' is nominated for removal.\n"
2135+
"hint: The use of symbolic links for symbolic refs is deprecated\n"
2136+
"hint: and will be removed in Git 3.0. The configuration that\n"
2137+
"hint: tells Git to use them is thus going away. You can unset\n"
2138+
"hint: it with:\n"
2139+
"hint:\n"
2140+
"hint:\tgit config unset core.preferSymlinkRefs\n"
2141+
"hint:\n"
2142+
"hint: Git will then use the textual symref format instead."));
2143+
warn_once = 0;
2144+
21302145
return ret;
21312146
}
21322147
#endif

t/t0600-reffiles-backend.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,9 +477,29 @@ test_expect_success SYMLINKS 'symref transaction supports symlinks' '
477477
prepare
478478
commit
479479
EOF
480-
git update-ref --no-deref --stdin <stdin &&
481-
test_path_is_symlink .git/TEST_SYMREF_HEAD &&
482-
test "$(test_readlink .git/TEST_SYMREF_HEAD)" = refs/heads/new
480+
git update-ref --no-deref --stdin <stdin 2>err &&
481+
if test_have_prereq WITH_BREAKING_CHANGES
482+
then
483+
test_path_is_file .git/TEST_SYMREF_HEAD &&
484+
echo "ref: refs/heads/new" >expect &&
485+
test_cmp expect .git/TEST_SYMREF_HEAD &&
486+
test_must_be_empty err
487+
else
488+
test_path_is_symlink .git/TEST_SYMREF_HEAD &&
489+
test "$(test_readlink .git/TEST_SYMREF_HEAD)" = refs/heads/new &&
490+
cat >expect <<-EOF &&
491+
warning: ${SQ}core.preferSymlinkRefs=true${SQ} is nominated for removal.
492+
hint: The use of symbolic links for symbolic refs is deprecated
493+
hint: and will be removed in Git 3.0. The configuration that
494+
hint: tells Git to use them is thus going away. You can unset
495+
hint: it with:
496+
hint:
497+
hint: git config unset core.preferSymlinkRefs
498+
hint:
499+
hint: Git will then use the textual symref format instead.
500+
EOF
501+
test_cmp expect err
502+
fi
483503
'
484504

485505
test_expect_success 'symref transaction supports false symlink config' '

0 commit comments

Comments
 (0)