diff options
Diffstat (limited to 'vcx')
| -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"; |
