Skip to content

Commit a9eeb0d

Browse files
committed
Merge branch 'ps/symlink-symref-deprecation' into seen
* ps/symlink-symref-deprecation: refs/files: deprecate writing symrefs as symbolic links
2 parents 0074466 + b290c14 commit a9eeb0d

4 files changed

Lines changed: 60 additions & 5 deletions

File tree

Documentation/BreakingChanges.adoc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,24 @@ 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. If set, symbolic refs like "HEAD" would be written as
300+
symbolic links instead of as a plain file using the symref format.
301+
+
302+
Symbolic references were initially always stored as a symbolic link. This was
303+
changed in 9b143c6e15 (Teach update-ref about a symbolic ref stored in a
304+
textfile., 2005-09-25), where a new symref format was introduced to store those
305+
symbolic refs in a plain file. In 9f0bb90d16 (core.prefersymlinkrefs: use
306+
symlinks for .git/HEAD, 2006-05-02), the Git project switched the default to use
307+
the symref format in favor of symbolic links.
308+
+
309+
The migration away from symbolic links has happened almost 20 years ago by now,
310+
and there is no known reason why one should prefer them nowadays. Furthermore,
311+
symbolic links are not supported on some platforms.
312+
+
313+
Note that for now, only the writing side for such symbolic links is deprecated.
314+
Reading such symbolic links is still supported for now.
315+
298316
== Superseded features that will not be deprecated
299317

300318
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. Writing
295+
symbolic links for symrefs will not be supported anymore.
293296

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

refs/files-backend.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,14 +2098,28 @@ static int commit_ref_update(struct files_ref_store *refs,
20982098
return 0;
20992099
}
21002100

2101-
#ifdef NO_SYMLINK_HEAD
2101+
#if defined(NO_SYMLINK_HEAD) || defined(WITH_BREAKING_CHANGES)
21022102
#define create_ref_symlink(a, b) (-1)
21032103
#else
21042104
static int create_ref_symlink(struct ref_lock *lock, const char *target)
21052105
{
2106+
static int warn_once = 1;
2107+
char *ref_path;
21062108
int ret = -1;
21072109

2108-
char *ref_path = get_locked_file_path(&lock->lk);
2110+
if (warn_once)
2111+
warning(_("'core.preferSymlinkRefs=true' is nominated for removal.\n"
2112+
"hint: The use of symbolic links for symbolic refs is deprecated\n"
2113+
"hint: and will be removed in Git 3.0. The configuration that\n"
2114+
"hint: tells Git to use them is thus going away. You can unset\n"
2115+
"hint: it with:\n"
2116+
"hint:\n"
2117+
"hint:\tgit config unset core.preferSymlinkRefs\n"
2118+
"hint:\n"
2119+
"hint: Git will then use the symref format instead."));
2120+
warn_once = 0;
2121+
2122+
ref_path = get_locked_file_path(&lock->lk);
21092123
unlink(ref_path);
21102124
ret = symlink(target, ref_path);
21112125
free(ref_path);

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 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)