Commit graph

86 commits

Author SHA1 Message Date
Adam Spiers
6cf41850b3 foldable: rename $target => $target_subdir
The $target variable was ambiguous, as it could have referred to the
path to the target directory, or the path to a sub-directory in the
target, as well as its intended meaning of a subpath relative to the
target directory.  So rename it to try to find the balance between
clarity and verbosity.
2024-04-01 22:39:32 +01:00
Adam Spiers
2851b36df4 find_stowed_path: rename $path / $dest to $pkg_path_from_cwd
$path is horribly vague, so rename to be more informative.
2024-04-01 22:39:32 +01:00
Adam Spiers
0daf352200 unstow_node: rename $path to $pkg_path_from_cwd
$path is horribly vague, so rename to be more informative.
2024-04-01 22:39:32 +01:00
Adam Spiers
6b9bbc9cbb link_dest_within_stow_dir: rename $path to $pkg_subpath
$path is horribly vague, so rename to be more informative.
2024-04-01 22:39:32 +01:00
Adam Spiers
170d161692 find_containing_marked_stow_dir: rename $path to $pkg_path_from_cwd
$path is horribly vague, so rename to be more informative.
2024-04-01 22:39:32 +01:00
Adam Spiers
75c892abc6 unstow_* helpers: rename $path to $pkg_path_from_cwd
$path is horribly vague, so rename to be more informative.
2024-04-01 22:39:32 +01:00
Adam Spiers
c0060443ee marked_stow_dir: rename $path to $dir
It's always a directory, so make this explicit.
2024-04-01 22:39:32 +01:00
Adam Spiers
caefb641b8 find_stowed_path: reintroduce missing comment lines
These lines were accidentally removed by 84367681.
2024-04-01 22:39:32 +01:00
Adam Spiers
10c86841de stow_contents / unstow_node: rename $target => $target_sub{dir,path}
This is very similar to a previous commit which did the same rename in
stow_node().

The $target variable was ambiguous, as it could have referred to the
path to the target directory, or the path to a sub-directory in the
target, as well as its intended meaning of a subpath relative to the
target directory.  So rename it to try to find the balance between
clarity and verbosity.
2024-04-01 22:39:32 +01:00
Adam Spiers
0782be7106 Remove unstow_*_orig() functions
Refactor the compat mode code to reuse the existing unstow_contents()
and unstow_node().  This allows us to remove the parallel versions in
unstow_contents_orig() and unstow_node(), which contained a lot of
duplicated code and were a significant maintenance burden.
2024-04-01 22:39:32 +01:00
Adam Spiers
456424c560 unstow_node_orig: replace a bunch of duplicated code with unstow_link_node() 2024-04-01 22:39:32 +01:00
Adam Spiers
517384407b unstow_node: extract new unstow_existing_node() sub 2024-04-01 22:39:32 +01:00
Adam Spiers
42cc1d2e60 unstow_node: extract new unstow_link_node() sub 2024-04-01 22:39:32 +01:00
Adam Spiers
cc592bdc44 unstow_node: extract new unstow_valid_link() sub 2024-04-01 22:39:32 +01:00
Adam Spiers
1f752a3c94 stow_node: rename $target => $target_subpath
The $target variable was ambiguous, as it could have referred to the
path to the target directory, or the path to a sub-directory in the
target, as well as its intended meaning of a subpath relative to the
target directory.  So rename it to try to find the balance between
clarity and verbosity.
2024-04-01 22:39:32 +01:00
Adam Spiers
0871a483cf rename $existing_source => $existing_link_dest
Source can be ambiguous, as mentioned in the manual.
2024-04-01 00:39:18 +01:00
Adam Spiers
e0212d4f49 stow_node(): fix odd whitespace 2024-04-01 00:35:35 +01:00
Adam Spiers
f60c203c45 should_skip_target(): add docs explaining its purpose 2024-04-01 00:34:39 +01:00
Adam Spiers
c2da8b416d do_link(): improve variable names 2024-04-01 00:34:19 +01:00
Adam Spiers
bffc347a19 Remove hard tabs 2024-04-01 00:06:24 +01:00
Adam Spiers
2f762e3908 Merge commit 'pullreqs/70' into dev 2024-03-31 23:41:02 +01:00
Adam Spiers
245dc83849 Stow.pm: reformat old comment style as pod
As previously noted, the old comment style was difficult to edit.
It's also not idiomatic Perl style, so reformat as pod.  This exposes
more of the inner workings of Stow as documentation, but that
shouldn't be a problem.

As part of this change, remove outdated and sometimes misleading
information about if/when each function throws an exception.
2024-03-31 23:19:08 +01:00
Adam Spiers
f4f3836c5f Stow.pm: rename $ldest to $link_dest for clarity 2024-03-31 15:38:38 +01:00
Adam Spiers
1be40c0532 Stow.pm: reformat comments
Some methods had comments with a prefix which made the paragraph
inconveniently narrow, and made refilling it really awkward.  So
switch to a more natural comment style.
2024-03-31 15:33:14 +01:00
Adam Spiers
8436768144 Eliminate erroneous warning when unstowing (#65)
When unstowing a package, cleanup_invalid_links() is invoked to remove
any invalid links owned by Stow.  It was invoking link_owned_by_package()
to check whether each existing link is owned by Stow.  This in turn
called find_stowed_path() which since 40a0807185 was not allowing for
the possibility that it could be passed a symlink *not* owned by Stow
with an absolute target and consequently emitting an erroneous warning.

So remove this erroneous warning, and refactor find_stowed_path()
to use two new helper functions for detecting stow directories:
link_dest_within_stow_dir() and find_containing_marked_stow_dir().
Also refactor the logic within each to be simpler and more accurate,
and add more test cases to the corresponding parts of the test suite.

Fixes #65.
Closes #103.

https://github.com/aspiers/stow/issues/65
2024-03-31 14:03:47 +01:00
Adam Spiers
541faf68eb cleanup_invalid_links: improve docs 2024-03-31 12:16:42 +01:00
Adam Spiers
a2beb7b371 Separate treatment of .stow and .nonstow marked dirs
Placing a .stow file in a directory tells Stow that this directory
should be considered a Stow directory.  This is already
well-documented.

There was an undocumented and slightly broken feature where placing a
.nonstow file in a directory was treated in exactly the same way.  The
intention was for .nonstow to cause Stow to skip stowing into and
unstowing from that directory and any of its descendants.  However, it
also caused Stow to consider symlinks into any of those directories as
owned by Stow, even though that was clearly not the intention.  So
separate treatment of .stow and .nonstow markers, so that while both
provide protection against Stow stowing and unstowing, only .stow
affects the symlink ownership logic in find_stowed_path() and
marked_stow_dir().

Probably no one uses the undocumented .nonstow feature, so it may make
sense to remove this in future.
2024-03-31 12:15:53 +01:00
Adam Spiers
d1480195b6 Move setting of cperl-indent-level to .dir-locals.el
This removes duplication.
2024-03-31 12:02:58 +01:00
Adam Spiers
9db0de3005 Add some helpful comments
Explain a few things in preparation for a bugfix.
2024-03-10 17:40:17 +00:00
Adam Spiers
9ce37d9575 Remove $stow_path parameter from unstow_{contents,node}{,_orig}()
Unlike with the stow_{contents,node}{,_orig}() counterpart functions,
when unstowing, it's not necessary to pass the $stow_path parameter
because it can never differ from $self->{stow_path}.

The stow_*() functions need this for the corner case of unfolding a
tree which is stowed from a different stow directory to the one being
used for the current stowing operation (see the "Multiple Stow
Directories" section of the manual).
2024-03-09 17:57:04 +00:00
Adam Spiers
4e2776224f Tweak text of error and debug messages 2024-03-09 17:57:04 +00:00
Adam Spiers
b7bf77da52 Add a missing period to the stow_contents() comments. 2024-03-09 17:57:04 +00:00
Adam Spiers
72084f6fec Add a comment explaining that $node_target can be adjusted for dot- prefix 2024-03-09 17:57:04 +00:00
Adam Spiers
a3700e7171 Add a comment explaining path in stow_contents() 2024-03-09 17:57:04 +00:00
Adam Spiers
20bee7428e Add a comment explaining $stow_path parameter of stow_contents()
At first sight this parameter looks redundant since we have
$self->{stow_path}, but in one case the value can differ from that,
so mention that explicitly.
2024-03-09 17:57:04 +00:00
Adam Spiers
f51fc1248c plan_*: rename $path to $pkg_path for clarity
$path is a vague variable name.
2024-03-09 17:57:04 +00:00
Adam Spiers
ee240c5bf2 cleanup_invalid_links: it's a bug if called with a non-directory 2021-04-15 15:11:30 +01:00
Adam Spiers
e76dda400a Skip unnecessary planning 2021-04-15 15:11:30 +01:00
Adam Spiers
c0c01a6c61 cleanup_invalid_links: improve handling of scheduled actions 2021-04-15 15:11:30 +01:00
Adam Spiers
208f383580 Further improve debug output 2021-04-15 15:11:30 +01:00
Adam Spiers
396357dc67 Rename path_owned_by_package() to link_owned_by_package() 2021-04-15 15:11:30 +01:00
Adam Spiers
832135e269 Make cleanup_invalid_links() more explicit
And add some debug.
2021-04-15 15:11:30 +01:00
Adam Spiers
86f4694d96 Improve debug indent levels 2021-04-15 15:11:30 +01:00
Adam Spiers
90278f854c Move to explicit debug indentation levels 2021-04-15 15:11:30 +01:00
Adam Spiers
8d7b7a7310 foldable(): fix debug indentation 2021-04-15 15:11:30 +01:00
Adam Spiers
9f4f8185ac should_skip_target_which_is_stow_dir(): fix debug indentation 2021-04-15 15:11:30 +01:00
ATuinDev
a41118d927
Fix missing variable 2020-05-25 22:26:31 +02:00
ATuinDev
a2db7a9c76
Add $level variable in stow_contents and stow_node
This variables is used to keep track of the current level in the source.
2020-05-25 22:21:31 +02:00
ATuinDev
d4e413536e
Fixes Bug #56727
Problem was that when running stow_contents/unstow_contents recursively from
stow_node/unstow_node the information for the source path (without the dot- to
. transformation) was lost.

In the case of stow_contents the solution is just to remove the leading
dots (..) from the $source path (since the $source path is passed as an argument
to the function)

In the case of unstow_contents the solution is the same as for stow_contents but
the arguments was now passed so I added it to the function.
2020-05-24 18:12:49 +02:00
Adam Spiers
40a0807185 Check that find_stowed_path $path matches relative/absolute with target
Watch out for a corner case probably only relevant in tests.
2019-06-28 15:24:50 +01:00