danny0838 / git-store-meta

Simple file metadata storing and applying for git.
MIT License
124 stars 19 forks source link

question: After setting up a repo, should a clone of that depot preserve file metadata? #10

Closed tcorman closed 6 years ago

tcorman commented 6 years ago

I might be misunderstand how this script works: with a few small mods I was able to get it working on Windows, and I've got a test repository with hooks enabled. Metadata files look like they are created correctly. When I clone that repository, however, the mod times on the cloned files are different from the source repository - I'd expect them to be the same. Am I misunderstanding the way the script works or is something not working as expected? Thanks!

danny0838 commented 6 years ago

git-store-meta is a script and won't run automatically except that a hook is set. Hooks must follow Git's rule and we currently only have pre-commit and post-checkout hook (see doc). Since there is no post-clone hook, the apply won't run after a clone, and you have to run it manually if you want to keep files' metadata consistent to the recorded ones.

tcorman commented 6 years ago

Per doc, it looks like a post-checkout hook should run after clone:

post-checkout



This hook is invoked when a 'git checkout' is run after having updated the
worktree.  The hook is given three parameters: the ref of the previous HEAD,
the ref of the new HEAD (which may or may not have changed), and a flag
indicating whether the checkout was a branch checkout (changing branches,
flag=1) or a file checkout (retrieving a file from the index, flag=0).
This hook cannot affect the outcome of 'git checkout'.

It is also run after 'git clone', unless the --no-checkout (-n) option is
used. The first parameter given to the hook is the null-ref, the second the
ref of the new HEAD and the flag is always 1. Likewise for 'git worktree add'
unless --no-checkout is used.
danny0838 commented 6 years ago

Hooks are not copied during cloning, and thus nothing would happen after repo A, which has git-store-meta scripts and hooks, is cloned into repo B. A template directory need to be specified to generate hooks in repo B, and they would run after cloning.

It's an interesting feature of Git. Sorry for missing that in prior.

tcorman commented 6 years ago

Where is the file metadata stored when you run --store? In .git-store-meta I see:

.git_store_meta f metafile f textfile1.txt f
danny0838 commented 6 years ago

By default it's stored in the .git_store_meta file, but you have to specified what fields to store or only the default fields (file name and type) are stored. For more details please read the manual.

danny0838 commented 6 years ago

Close stale issue. Response if you still have further question or information.