From c1315e005c85b4944ecfe05afdfb0c458287a106 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sat, 18 Apr 2026 15:03:24 +0800 Subject: Fix staging symlinks. --- vcx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'vcx') 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"; -- cgit v1.2.3