przemoc / metastore

Store and restore metadata from a filesystem.
http://software.przemoc.net/#metastore
GNU General Public License v2.0
169 stars 31 forks source link

Record attributes only for specified dirs/files #50

Closed wirawan0 closed 3 years ago

wirawan0 commented 4 years ago

Hi, I'd like to propose that an command-line option is added to metastore so that it records metadata only for files and directories specified by the user. This will be very helpful for Git workflow, where the ones we want to keep track and recorded in Git repo eventually are just those files/dirs under GIt control. Currently the metadata of ALL files found in the current directory and its subdirs are recorded, so it becomes superfluous. This feature is complementary to #8 , but more specifically will be relevant to Git.

przemoc commented 3 years ago

You can already achieve what you want (as described in title of the issue) by providing paths you are interested in as arguments for metastore.

$ # store metadata only for specified files and directories
$ metastore -s .gitignore man1/
$ # dump content from .metadata
$ metastore -d
-rw-r--r--      przemoc other   2018-01-02 18:31:37.672376115 +0100     ./.gitignore
drwxr-sr-x      przemoc other   2016-12-03 00:58:00.140686412 +0100     ./man1/
-rw-r--r--      przemoc other   2016-12-03 00:58:00.140686412 +0100     ./man1/metastore.1

But maybe what you're asking for is something like this?

If yes, then I may accept your request and create dedicated enhancement issue.


Switching gears, what you put in the description of the issue is a bit more specific, because you are referring specifically to the files tracked by git being the specified ones.

metastore is not meant to be tied to any VCS, be it svn, pijul, perforce, hg, git, fossil, darcs, or any other. So I'm against integrating VCS-related features into metastore. Example of such unwanted feature can be seen in igordcard/metastore@52ea2735cf10 (further changed in igordcard/metastore@4c831a0586a7).

In case of git it can be achieved in metastore using:

$ git ls-files -z | xargs -0 metastore -s     # store
$ git ls-files -z | xargs -0 metastore -a -m  # apply

Of course it's not bulletproof, because with long list of files, xargs will call metastore more than once, and each subsequent invocation will overwrite previous .metadata file. So having -T option (and equivalent configuration entry when #7 will be implemented) will be still useful.