git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrej Zhilenkov <azhilenkov@gmail.com>
To: git@vger.kernel.org
Subject: Update symlinks after changing core.symlinks
Date: Wed, 2 Apr 2025 12:18:45 +0500	[thread overview]
Message-ID: <CAArAzAoU9qDj+yLi3pA6wFYdTAk0UvQk4omSWM1RL4D9w5fw_w@mail.gmail.com> (raw)

Hello! Is there a direct way to update symlinks in repo after changing
core.symlinks?
E.g. update plain files, if it was false, with symlinks or vice versa.

I've tried `checkout` and `reset` but they have no effect in this case
(see the snippet below). The only two things that are working:
- checking out a commit before the symlink was introduced and then
checking out any commit after (need to know that special commit to
make it work for those specific symlinks, not practical)
- removing symlinked files and checking them out specifically (need to
either have a list or somehow search for those files to reset)

Is this the way to do it or is there an alternative?

Snippet output:
```
Using temporary directory: /tmp/tmp.gynGH2VcB1
Checking symlink status after creation:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after checkout:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after reset:
lrwxrwxrwx 1 root root 12 Apr  2 07:12 symlink.txt -> original.txt
Checking symlink status after removal and checkout:
-rw-r--r-- 1 root root 12 Apr  2 07:12 symlink.txt
```

Snippet:
```
%%shell
set -e

# Create a temporary directory
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
echo "Using temporary directory: $TMP_DIR"

# Initialize a new Git repository
git init -q
git config user.name "Test User"
git config user.email "test@example.com"

# Create and commit a regular file
echo "Hello World" > original.txt
git add original.txt
git commit -qm "Add original file"

# Add a symlink to the original file and commit
ln -s original.txt symlink.txt
git add symlink.txt
git commit -qm "Add symlink to original file"

echo "Checking symlink status after creation:"
ls -l symlink.txt

# Ensure core.symlinks is set to false
git config core.symlinks false

# Checkout just the symlink file from the master branch
git checkout -- symlink.txt
echo "Checking symlink status after checkout:"
ls -l symlink.txt

# Try resetting just the symlink file
git reset -- symlink.txt
echo "Checking symlink status after reset:"
ls -l symlink.txt

# Remove the symlink and re-checkout it
rm symlink.txt
echo "Checking symlink status after removal and checkout:"
git checkout -- symlink.txt
ls -l symlink.txt

# Cleanup
cd ..
rm -rf "$TMP_DIR"
```

             reply	other threads:[~2025-04-02  7:18 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-02  7:18 Andrej Zhilenkov [this message]
2025-04-02 22:41 ` Update symlinks after changing core.symlinks brian m. carlson
2025-04-03 22:25   ` brian m. carlson
2025-04-04  5:51     ` Andrej Zhilenkov
2025-04-04  7:31       ` brian m. carlson
2025-04-10 19:29         ` Andrej Zhilenkov

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=CAArAzAoU9qDj+yLi3pA6wFYdTAk0UvQk4omSWM1RL4D9w5fw_w@mail.gmail.com \
    --to=azhilenkov@gmail.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).