Git Product home page Git Product logo

Comments (10)

lassik avatar lassik commented on June 5, 2024 6

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
...

from stow.

Deichscheich avatar Deichscheich commented on June 5, 2024

Great work in outlining this, lassik! This feature would be reeeeally useful.

from stow.

SyntaxColoring avatar SyntaxColoring commented on June 5, 2024

👍

from stow.

aspiers avatar aspiers commented on June 5, 2024

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.

from stow.

lassik avatar lassik commented on June 5, 2024

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.

from stow.

SyntaxColoring avatar SyntaxColoring commented on June 5, 2024

Yeah, that seems like overkill.

from stow.

sebastienbarre avatar sebastienbarre commented on June 5, 2024

This would be a nice feature. Did it make it in?

from stow.

aspiers avatar aspiers commented on June 5, 2024

Nope, someone has to code it first ;-)

from stow.

astier avatar astier commented on June 5, 2024

Would be really cool if it would be possible to overwrite existing files.

from stow.

H3mul avatar H3mul commented on June 5, 2024

If someone badly needs this (like I do!) and can't wait for this to be merged into upstream, and is on Arch, you're welcome to my PKGBUILD in the meantime.

from stow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.