Open lassik opened 9 years ago
More sketching:
What if we instead moved the backup files into a designated backup directory that mirrors directory structure in the same way that stow packages do. E.g.
$ tree -a --charset ascii
.
|-- .git
|-- .gitignore
`-- my-configs
`-- etc
`-- ntp.conf
$ cat .gitignore
/defaults/
$ stow my-configs -vvt / --backupdir defaults
...
MKDIR: defaults # because it didn't exist already
MKDIR: defaults/etc # because it didn't exist already
COPY: /etc/ntp.conf => defaults/etc/ntp.conf # or this could be a rename...
REMOVE: /etc/ntp.conf # ...if file system boundaries are not crossed
LINK: etc/ntp.conf => /etc/ntp.conf
...
$ tree -a --charset ascii
.
|-- defaults
| `-- etc
| `-- ntp.conf
|-- .git
|-- .gitignore
`-- my-configs
`-- etc
`-- ntp.conf
If the user wanted to, they could also append a filename extension of their choice to all backup files. If they didn't give such an extension, nothing would be appended. E.g.:
$ stow my-configs -vvt / --backupext .orig
...
RENAME: /etc/ntp.conf => /etc/ntp.conf.orig
LINK: etc/ntp.conf => /etc/ntp.conf
...
It would also be possible to combine --backupdir
and --backupext
in a natural way:
$ stow my-configs -vvt / --backupdir defaults --backupext .orig
...
COPY: /etc/ntp.conf => defaults/etc/ntp.conf.orig
REMOVE: /etc/ntp.conf
LINK: etc/ntp.conf => /etc/ntp.conf
...
Great work in outlining this, lassik! This feature would be reeeeally useful.
:+1:
Yes thanks, this is a good feature request. Please look at patch(1)
for ideas on how to define options which control the algorithm for choosing where to back up to.
Thanks for the interest!
Good tip on patch(1)
. The above proposed --backupdir
and --backupext
seem equivalent to patch
's --prefix
and --suffix
, respectively. (Except that patch
's --prefix
need not be a directory if it doesn't end in a slash.)
patch
's naming scheme support seems very comprehensive with the --basename-prefix
and --version-control
options (numbered backup files, etc.) in addition to the above. Do you think anyone would find these useful in stow
's context? My personal intuition is that they would be over the top.
Yeah, that seems like overkill.
This would be a nice feature. Did it make it in?
Nope, someone has to code it first ;-)
Would be really cool if it would be possible to overwrite existing files.
Hello!
Thank you for stow -- I'm enjoying it a lot. It has become the first tool that I install on a new machine after git. Also, I hope github is an OK channel for sending feature requests.
Here's my request: It'd be nice to have a new command line option
--orig
(or similar) to make backups of conflicting files in the target directory instead of failing on conflict. For example:hosts
=>hosts.orig
ntp.conf
=>ntp.conf.orig
.bashrc
=>.bashrc.orig
I often use stow to link files from a git repo into
$HOME
or/etc
, and Linux distributions ship with default configuration files in these locations that stow will trip over. The--adopt
option does not solve my problem because I don't want to copy the OS default configs into my git repo - I want to do the opposite and overwrite the OS default configs (but keep backups of them).Leaving each backup file in the same directory as the original and using a constant backup extension (
.orig
) has the nice effect that one can do e.g.find /etc -name "*.orig"
to find all overwritten configs. Likewise, it's fairly easy to run diff to see changes from the OS defaults.Here's a demonstration of what currently happens:
This is what I would like to have:
Here's a succint description of the behavior that
--orig
would have, covering edge cases:The option could also be named
--backup
or similar, but I personally like--orig
because it's short and mnemonic (it reminds the user that the backup filename will have the extension.orig
, which is also a de facto standard extension for such files).Would you accept a feature like this into stow?
Kind regards, Lassi