From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 2/4] refs: mostly remove core.preferSymlinkRefs
Date: Wed, 18 Sep 2024 16:28:23 -0700 [thread overview]
Message-ID: <20240918232825.2627999-3-gitster@pobox.com> (raw)
In-Reply-To: <20240918232825.2627999-1-gitster@pobox.com>
This step and the next step are for Git 3.0.
Now we are preparing for a big Git 3.0 transition after warning
against use of this configuration variable to create a new symlink
that represents a symbolic ref for N months, it is time to actually
remove the support of the configuration variable.
In this patch, we mostly ignore core.preferSymlinkRefs and always
create a textual symref when we are asked to create a symref, but
when core.preferSymlinkRefs would have caused us to use a symbolic
link in an older version of Git, we will issue a warning. We also
have in our build infrastructure to selectively set the CPP macro
NO_SYMLINK_HEAD, but an accompanying patch will remove them.
The final warning is meant to help users who set the configuration
variable and expected it to create a symlink, but instead got a
textual symref. They may not even recognise the configuration after
they set it long time ago and forgot about it by now, so we keep the
"git config --help" entry for the variable to help them recall what
it was about.
After a few releases, we will get rid of this warning and the
codebase will look as if such a configuration variable never
existed, but we are not quite there yet.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
Documentation/config/core.txt | 4 ++--
refs/files-backend.c | 29 +++---------------------
t/t0600-reffiles-backend.sh | 42 +++++++++++++++++++++++------------
3 files changed, 33 insertions(+), 42 deletions(-)
diff --git a/Documentation/config/core.txt b/Documentation/config/core.txt
index f0245f5050..a6f67cab27 100644
--- a/Documentation/config/core.txt
+++ b/Documentation/config/core.txt
@@ -285,10 +285,10 @@ CIFS/Microsoft Windows.
+
False by default.
-core.preferSymlinkRefs (deprecated)::
+core.preferSymlinkRefs (removed)::
Instead of the default "symref" format for HEAD and other
symbolic reference files, use symbolic links. The support
- for this variable will be dropped in Git 3.0.
+ for this variable was dropped in Git 3.0.
core.alternateRefsCommand::
When advertising tips of available history from an alternate, use the shell to
diff --git a/refs/files-backend.c b/refs/files-backend.c
index c40a248b9f..1296272252 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2011,26 +2011,6 @@ static int commit_ref_update(struct files_ref_store *refs,
return 0;
}
-#ifdef NO_SYMLINK_HEAD
-#define create_ref_symlink(a, b) (-1)
-#else
-static int create_ref_symlink(struct ref_lock *lock, const char *target)
-{
- int ret = -1;
-
- char *ref_path = get_locked_file_path(&lock->lk);
- unlink(ref_path);
- ret = symlink(target, ref_path);
- free(ref_path);
-
- if (ret)
- fprintf(stderr, "no symlink - falling back to symbolic ref\n");
- else
- warning("core.preferSymlinkRefs will be removed in Git 3.0");
- return ret;
-}
-#endif
-
static int create_symref_lock(struct ref_lock *lock, const char *target,
struct strbuf *err)
{
@@ -3003,13 +2983,10 @@ static int files_transaction_finish(struct ref_store *ref_store,
}
}
- /*
- * We try creating a symlink, if that succeeds we continue to the
- * next update. If not, we try and create a regular symref.
- */
+ /* Warn against core.preferSymlinkRefs set to true */
if (update->new_target && prefer_symlink_refs)
- if (!create_ref_symlink(lock, update->new_target))
- continue;
+ /* we used to, but no longer, create a symlink here */
+ warning("core.preferSymlinkRefs was removed in Git 3.0");
if (update->flags & REF_NEEDS_COMMIT) {
clear_loose_ref_cache(refs);
diff --git a/t/t0600-reffiles-backend.sh b/t/t0600-reffiles-backend.sh
index d369330562..4e517cdc13 100755
--- a/t/t0600-reffiles-backend.sh
+++ b/t/t0600-reffiles-backend.sh
@@ -468,26 +468,40 @@ test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
esac
'
-test_expect_success SYMLINKS 'symref transaction supports symlinks' '
+test_expect_success SYMLINKS 'symlinks used as symrefs are still supported' '
test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD || :" &&
git update-ref refs/heads/new HEAD &&
- test_config core.prefersymlinkrefs true &&
- cat >stdin <<-EOF &&
- start
- symref-create TEST_SYMREF_HEAD refs/heads/new
- prepare
- commit
- EOF
- git update-ref --no-deref --stdin <stdin 2>stderr &&
+ # manually do this, as core.prefersymlinkrefs no longer
+ # affects how a symref is created (as a textual symref).
+ ln -f -s refs/heads/new .git/TEST_SYMREF_HEAD &&
test_path_is_symlink .git/TEST_SYMREF_HEAD &&
- test "$(test_readlink .git/TEST_SYMREF_HEAD)" = refs/heads/new &&
- test_grep "core\.preferSymlinkRefs will be removed" stderr
+ echo refs/heads/new >expect &&
+ git symbolic-ref TEST_SYMREF_HEAD >actual &&
+ test_cmp actual expect
+'
+
+test_expect_success 'core.prefersymlinkrefs gets a warning' '
+ test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD || :" &&
+ git update-ref refs/heads/new HEAD &&
+
+ test_config core.prefersymlinkrefs true &&
+ git symbolic-ref TEST_SYMREF_HEAD refs/heads/new 2>stderr &&
+ test_grep "core\.preferSymlinkRefs was removed" stderr &&
+
+ git symbolic-ref -d TEST_SYMREF_HEAD &&
+ git config core.prefersymlinkrefs false &&
+ git symbolic-ref TEST_SYMREF_HEAD refs/heads/new 2>stderr &&
+ test_grep ! "core\.preferSymlinkRefs was removed" stderr &&
+
+ git symbolic-ref -d TEST_SYMREF_HEAD &&
+ git config --unset core.prefersymlinkrefs &&
+ git symbolic-ref TEST_SYMREF_HEAD refs/heads/new 2>stderr &&
+ test_grep ! "core\.preferSymlinkRefs was removed" stderr
'
-test_expect_success 'symref transaction supports false symlink config' '
+test_expect_success 'symref transaction' '
test_when_finished "git symbolic-ref -d TEST_SYMREF_HEAD || :" &&
git update-ref refs/heads/new HEAD &&
- test_config core.prefersymlinkrefs false &&
cat >stdin <<-EOF &&
start
symref-create TEST_SYMREF_HEAD refs/heads/new
@@ -499,7 +513,7 @@ test_expect_success 'symref transaction supports false symlink config' '
git symbolic-ref TEST_SYMREF_HEAD >actual &&
echo refs/heads/new >expect &&
test_cmp expect actual &&
- test_grep ! "core\.preferSymlinkRefs will be removed" stderr
+ test_grep ! "core\.preferSymlinkRefs was removed" stderr
'
test_done
--
2.46.1-742-g4240f61078
next prev parent reply other threads:[~2024-09-18 23:28 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-18 23:28 [PATCH 0/4] deprecating core.preferSymlinkRefs Junio C Hamano
2024-09-18 23:28 ` [PATCH 1/4] refs: deprecate core.preferSymlinkRefs Junio C Hamano
2024-09-30 8:45 ` Patrick Steinhardt
2024-09-18 23:28 ` Junio C Hamano [this message]
2024-09-30 19:28 ` [PATCH 2/4] refs: mostly remove core.preferSymlinkRefs Jeff King
2024-09-30 20:13 ` Junio C Hamano
2024-09-18 23:28 ` [PATCH 3/4] refs: remove NO_SYMLINK_HEAD Junio C Hamano
2024-09-18 23:28 ` [PATCH 4/4] refs: remove the last remnants of core.preferSymlinkRefs Junio C Hamano
2024-09-18 23:38 ` [PATCH 0/4] deprecating core.preferSymlinkRefs Derrick Stolee
2024-09-19 0:26 ` Junio C Hamano
2024-09-30 8:45 ` Patrick Steinhardt
2024-09-30 18:21 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240918232825.2627999-3-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).