unstow_link_node(): don't register conflicts when unstowing unowned links
This commit is contained in:
parent
06fdfc185f
commit
744ba651f5
2 changed files with 10 additions and 48 deletions
|
@ -830,19 +830,10 @@ sub unstow_link_node {
|
|||
my ($existing_pkg_path_from_cwd, $existing_stow_path, $existing_package) =
|
||||
$self->find_stowed_path($target_subpath, $link_dest);
|
||||
if (not $existing_pkg_path_from_cwd) {
|
||||
if ($self->{compat}) {
|
||||
# We're traversing the target tree not the package tree,
|
||||
# so we definitely expect to find stuff not owned by stow.
|
||||
# Therefore we can't flag a conflict.
|
||||
return;
|
||||
}
|
||||
else {
|
||||
$self->conflict(
|
||||
'unstow',
|
||||
$package,
|
||||
"existing target is not owned by stow: $target_subpath => $link_dest"
|
||||
);
|
||||
}
|
||||
# The user is unstowing the package, so they don't want links to it.
|
||||
# Therefore we should allow them to have a link pointing elsewhere
|
||||
# which would conflict with the package if they were stowing it.
|
||||
debug(5, 3, "Ignoring unowned link $target_subpath => $link_dest");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
41
t/unstow.t
41
t/unstow.t
|
@ -154,46 +154,17 @@ subtests("existing link is owned by stow but is invalid so it gets removed anywa
|
|||
);
|
||||
});
|
||||
|
||||
subtest("Existing link is not owned by stow", sub {
|
||||
plan tests => 2;
|
||||
$ENV{HOME} = $ABS_TEST_DIR;
|
||||
cd($repo);
|
||||
cd("$TEST_DIR/target");
|
||||
my $stow = new_Stow();
|
||||
subtests("Existing invalid link is not owned by stow", sub {
|
||||
my ($stow) = @_;
|
||||
plan tests => 3;
|
||||
|
||||
make_path('../stow/pkg5/bin5');
|
||||
make_invalid_link('bin5', '../not-stow');
|
||||
|
||||
$stow->plan_unstow('pkg5');
|
||||
is($stow->get_conflict_count, 1, 'conflict count');
|
||||
my %conflicts = $stow->get_conflicts();
|
||||
is_deeply(
|
||||
\%conflicts,
|
||||
{
|
||||
'unstow' => {
|
||||
'pkg5' => [
|
||||
'existing target is not owned by stow: bin5 => ../not-stow'
|
||||
]
|
||||
}
|
||||
}
|
||||
=> "existing link not owned by stow"
|
||||
);
|
||||
});
|
||||
|
||||
subtest("Existing link is not owned by stow (compat mode)", sub {
|
||||
plan tests => 2;
|
||||
$ENV{HOME} = $COMPAT_ABS_TEST_DIR;
|
||||
cd($repo);
|
||||
cd("$COMPAT_TEST_DIR/target");
|
||||
my $stow = new_compat_Stow();
|
||||
|
||||
make_path('../stow/pkg5/bin5');
|
||||
make_invalid_link('bin5', '../not-stow');
|
||||
|
||||
$stow->plan_unstow('pkg5');
|
||||
# Unlike the non-compat test above, this doesn't cause any conflicts.
|
||||
ok(-l 'bin5');
|
||||
is(readlink('bin5'), '../not-stow' => "existing link not owned by stow");
|
||||
is($stow->get_conflict_count, 0, 'conflict count');
|
||||
ok(-l 'bin5', 'invalid link not removed');
|
||||
is(readlink('bin5'), '../not-stow' => "invalid link not changed");
|
||||
});
|
||||
|
||||
subtests("Target already exists, is owned by stow, but points to a different package", sub {
|
||||
|
|
Loading…
Reference in a new issue