The '--dotfiles' option does not work as expected in conjunction with tree folding

Hannes Härn <[email protected]> Sun, 5 Jan 2025 22:36:34 +0100
Newsgroups gmane.comp.gnu.stow.bugs
Message-ID <CAEN6n1=M3cBS-mtTtvLW9A-WxJhBnY-vXLsFwMUR+_DQEauZMQ@mail.gmail.com>
--0000000000007a3b71062afc4ee0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hello,

The behaviour of the '--dotfiles' option seems unexpected when stow folds
subtrees containing 'dot-' prefixed files. It appears that tree folding
takes precedence over '--dotfiles', which is unintuitive as we are
explicitly requesting translation to a dotfile. I have created an issue on
GitHub about this (#120 <https://github.com/aspiers/stow/issues/120>), but
I didn't know if that was enough or if I needed to report it here as well.

Steps to reproduce:
$ tree -a ~
/home/user/
...
=E2=94=94=E2=94=80=E2=94=80 stow
=E2=94=94=E2=94=80=E2=94=80 stow-dir
=E2=94=94=E2=94=80=E2=94=80 pkg-dir
=E2=94=94=E2=94=80=E2=94=80 dot-file

$ cd ~/stow && stow --dotfiles stow-dir

Expected behaviour:
$ tree -a ~
/home/user/
...
=E2=94=9C=E2=94=80=E2=94=80 pkg-dir
=E2=94=82 =E2=94=94=E2=94=80=E2=94=80 .file -> ../stow/stow-dir/pkg-dir/dot=
-file
=E2=94=94=E2=94=80=E2=94=80 stow
=E2=94=94=E2=94=80=E2=94=80 stow-dir
=E2=94=94=E2=94=80=E2=94=80 pkg-dir
=E2=94=94=E2=94=80=E2=94=80 dot-file

Actual behaviour:
$ tree -a ~
/home/user/
...
=E2=94=9C=E2=94=80=E2=94=80 pkg-dir -> stow/stow-dir/pkg-dir
=E2=94=94=E2=94=80=E2=94=80 stow
=E2=94=94=E2=94=80=E2=94=80 stow-dir
=E2=94=94=E2=94=80=E2=94=80 pkg-dir
=E2=94=94=E2=94=80=E2=94=80 dot-file

Would it be possible to modify the implementation of '--dotfiles' or
introduce an option to control this behaviour? While a workaround is to use
'--no-folding', it is not ideal since you lose a lot of functionality.
Another workaround is to manually create the 'pkg-dir' prior to stowing,
which would then also result in the expected behaviour shown above.

Additionally, if this new behaviour is to be implemented, I'm assuming it
would be impossible/out of scope to have 'pkg-dir' removed when unstowing
with 'stow -D stow-dir'. This means that stow will leave empty directories
after itself even when it "owns" everything, which I understand may not
align with design guidelines. Should it be implemented however, a note in
the '--dotfiles' documentation warning about this would likely also be
needed.

Best regards,
Hannes

--0000000000007a3b71062afc4ee0
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div>Hello,</div><div><br></div><div>The =
behaviour of the &#39;--dotfiles&#39; option seems unexpected when stow fol=
ds subtrees containing &#39;dot-&#39; prefixed files. It appears that tree =
folding takes precedence over &#39;--dotfiles&#39;, which is unintuitive as=
 we are explicitly requesting translation to a dotfile. I have created an i=
ssue on GitHub about this (<a href=3D"https://github.com/aspiers/stow/issue=
s/120">#120</a>), but I didn&#39;t know if that was enough or if I needed t=
o report it here as well.</div><div><br></div><div>Steps to reproduce:</div=
><div>$ tree -a ~</div><div>/home/user/</div><div>...</div><div>=E2=94=94=
=E2=94=80=E2=94=80 stow</div><div>=E2=80=83=E2=94=94=E2=94=80=E2=94=80 stow=
-dir</div><div>=E2=80=83=E2=80=83=E2=94=94=E2=94=80=E2=94=80 pkg-dir</div><=
div>=E2=80=83=E2=80=83=E2=80=83=E2=94=94=E2=94=80=E2=94=80 dot-file</div><d=
iv><br></div><div>$ cd ~/stow &amp;&amp; stow --dotfiles stow-dir</div><div=
><br></div><div>Expected behaviour:</div><div>$ tree -a ~</div><div>/home/u=
ser/</div><div>...</div><div>=E2=94=9C=E2=94=80=E2=94=80 pkg-dir</div><div>=
=E2=94=82=E2=80=83=E2=94=94=E2=94=80=E2=94=80 .file -&gt; ../stow/stow-dir/=
pkg-dir/dot-file</div><div>=E2=94=94=E2=94=80=E2=94=80 stow</div><div>=E2=
=80=83=E2=94=94=E2=94=80=E2=94=80 stow-dir</div><div>=E2=80=83=E2=80=83=E2=
=94=94=E2=94=80=E2=94=80 pkg-dir</div><div>=E2=80=83=E2=80=83=E2=80=83=E2=
=94=94=E2=94=80=E2=94=80 dot-file</div><div><br></div><div>Actual behaviour=
:</div><div>$ tree -a ~</div><div>/home/user/</div><div>...</div><div>=E2=
=94=9C=E2=94=80=E2=94=80 pkg-dir -&gt; stow/stow-dir/pkg-dir</div><div>=E2=
=94=94=E2=94=80=E2=94=80 stow</div><div>=E2=80=83=E2=94=94=E2=94=80=E2=94=
=80 stow-dir</div><div>=E2=80=83=E2=80=83=E2=94=94=E2=94=80=E2=94=80 pkg-di=
r</div><div>=E2=80=83=E2=80=83=E2=80=83=E2=94=94=E2=94=80=E2=94=80 dot-file=
</div><div><br></div><div>Would it be possible to modify the implementation=
 of &#39;--dotfiles&#39; or introduce an option to control this behaviour? =
While a workaround is to use &#39;--no-folding&#39;, it is not ideal since =
you lose a lot of functionality. Another workaround is to manually create t=
he &#39;pkg-dir&#39; prior to stowing, which would then also result in the =
expected behaviour shown above.</div><div><br></div><div>Additionally, if t=
his new behaviour is to be implemented, I&#39;m assuming it would be imposs=
ible/out of scope to have &#39;pkg-dir&#39; removed when unstowing with &#3=
9;stow -D stow-dir&#39;. This means that stow will leave empty directories =
after itself even when it &quot;owns&quot; everything, which I understand m=
ay not align with design guidelines. Should it be implemented however, a no=
te in the &#39;--dotfiles&#39; documentation warning about this would likel=
y also be needed.</div><div><br></div><div>Best regards,</div><div>Hannes</=
div></div></div>

--0000000000007a3b71062afc4ee0--