diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-04-18 15:03:24 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-04-18 15:03:24 +0800 |
| commit | c1315e005c85b4944ecfe05afdfb0c458287a106 (patch) | |
| tree | 6e10f47329db9a146d471c0b867c1487f5834fc5 | |
| parent | 42db0341b2b5c05739d3f498f7cae7258fc88e69 (diff) | |
| download | urn-c1315e005c85b4944ecfe05afdfb0c458287a106.tar.gz | |
Fix staging symlinks.
| -rw-r--r-- | vcx | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -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"; |
