summaryrefslogtreecommitdiffstats
path: root/vcx
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-04-18 15:03:24 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-04-18 15:03:24 +0800
commitc1315e005c85b4944ecfe05afdfb0c458287a106 (patch)
tree6e10f47329db9a146d471c0b867c1487f5834fc5 /vcx
parent42db0341b2b5c05739d3f498f7cae7258fc88e69 (diff)
downloadurn-c1315e005c85b4944ecfe05afdfb0c458287a106.tar.gz
Fix staging symlinks.
Diffstat (limited to 'vcx')
-rw-r--r--vcx16
1 files changed, 14 insertions, 2 deletions
diff --git a/vcx b/vcx
index 3691523..f30e1f1 100644
--- a/vcx
+++ b/vcx
@@ -173,7 +173,13 @@ sub run_add {
# Snapshot to staging area
my $stg_path = File::Spec->catfile(TMP_DIR, $wrk_entry->{path});
make_path(dirname($stg_path));
- copy($wrk_entry->{path}, $stg_path);
+
+ if (!-l $wrk_entry->{path}) {
+ copy($wrk_entry->{path}, $stg_path) or die "Failed to stage file: $!";
+ } else {
+ my $link_target = readlink($wrk_entry->{path});
+ symlink($link_target, $stg_path) or die "Failed to stage symlink: $!";
+ }
if ($current_hash eq $idx_entry->{s_hash}) {
print $out join("\t", $idx_entry->{s_hash},
@@ -192,7 +198,13 @@ sub run_add {
my $hash = hash_file_content($wrk_entry->{path});
my $stg_path = File::Spec->catfile(TMP_DIR, $wrk_entry->{path});
make_path(dirname($stg_path));
- copy($wrk_entry->{path}, $stg_path);
+
+ if (!-l $wrk_entry->{path}) {
+ copy($wrk_entry->{path}, $stg_path) or die "Failed to stage file: $!";
+ } else {
+ my $link_target = readlink($wrk_entry->{path});
+ symlink($link_target, $stg_path) or die "Failed to stage symlink: $!";
+ }
print $out join("\t", $hash, $hash, $wrk_entry->{mtime},
$wrk_entry->{size}, $wrk_entry->{path}) . "\n";