From 7b43622dd9ff7b8793d1c08727f84ac5069d3fb4 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Thu, 1 Jan 2015 19:02:46 +0000 Subject: [PATCH] fix stowing of relative links when --no-folding is used With a tree like this: . |-- stow | `-- pkg | `-- lib | |-- itk-current -> itk4.0.0 | `-- itk4.0.0 | `-- libitk4.0.0.so `-- target `-- lib |-- itk4.0.0 -> ../../stow/pkg/lib/itk4.0.0 `-- libfoo-1.2.3.so stowing pkg with the --no-folding option resulted in itk-current being "unpacked": . `-- target `-- lib |-- itk-current | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk-current/libitk4.0.0.so |-- itk4.0.0 | `-- libitk4.0.0.so -> ../../../stow/pkg/lib/itk4.0.0/libitk4.0.0.so `-- libfoo-1.2.3.so This commit fixes it so that it gets stowed as a symlink: . `-- target `-- lib ... |-- itk-current -> ../../stow/pkg/lib/itk-current ... Thanks to Gabriele Balducci for reporting this problem: http://thread.gmane.org/gmane.comp.gnu.stow.general/6676 --- lib/Stow.pm.in | 2 +- t/stow.t | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Stow.pm.in b/lib/Stow.pm.in index 2e0b71e..851bb86 100755 --- a/lib/Stow.pm.in +++ b/lib/Stow.pm.in @@ -520,7 +520,7 @@ sub stow_node { } } } - elsif ($self->{'no-folding'} && -d $path) { + elsif ($self->{'no-folding'} && -d $path && ! -l $path) { $self->do_mkdir($target); $self->stow_contents( $self->{stow_path}, diff --git a/t/stow.t b/t/stow.t index 793e14e..92141fc 100755 --- a/t/stow.t +++ b/t/stow.t @@ -7,7 +7,7 @@ use strict; use warnings; -use Test::More tests => 112; +use Test::More tests => 118; use Test::Output; use English qw(-no_match_vars); @@ -461,6 +461,7 @@ sub create_pkg { # yet stowed make_dir ("$stow_pkg/$id-$pkg-only-new2/subdir"); make_file("$stow_pkg/$id-$pkg-only-new2/subdir/$id-file-$pkg"); + make_link("$stow_pkg/$id-$pkg-only-new2/current", "subdir"); # create a hierarchy specific to this package which is already # stowed via a folded tree @@ -487,7 +488,7 @@ $stow->plan_stow('no-folding-a'); is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); my @tasks = $stow->get_tasks; use Data::Dumper; -is(scalar(@tasks), 12 => "6 dirs, 6 links") || warn Dumper(\@tasks); +is(scalar(@tasks), 13 => "6 dirs, 7 links") || warn Dumper(\@tasks); $stow->process_tasks(); sub check_no_folding { @@ -508,6 +509,8 @@ sub check_no_folding { is_dir_not_symlink("no-folding-$pkg-only-new2/subdir"); is_link("no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg", "../../$stow_pkg/no-folding-$pkg-only-new2/subdir/no-folding-file-$pkg"); + is_link("no-folding-$pkg-only-new2/current", + "../$stow_pkg/no-folding-$pkg-only-new2/current"); # check shared tree is not folded. first time round this will be # newly stowed. @@ -530,7 +533,7 @@ $stow = new_Stow('no-folding' => 1); $stow->plan_stow('no-folding-b'); is_deeply([ $stow->get_conflicts ], [] => 'no conflicts with --no-folding'); @tasks = $stow->get_tasks; -is(scalar(@tasks), 10 => '4 dirs, 6 links') || warn Dumper(\@tasks); +is(scalar(@tasks), 11 => '4 dirs, 7 links') || warn Dumper(\@tasks); $stow->process_tasks(); check_no_folding('a');