Support --fields for --install
Closed this issue · 8 comments
During the install process, only -d option is take in mind.
So an additional "git-store-meta.pl --store -f " is required, but can be avoided.
An example from a new repo:
# .git/hooks/git-store-meta.pl --install -d -f mtime,atime,mode,user,group,uid,gid,acl
installing hooks...
git directory: `.git'
created `.git/hooks/pre-commit'
created `.git/hooks/post-checkout'
created `.git/hooks/post-merge'
# cat .git_store_meta
# generated by git-store-meta 1.3.2
<file> <type> <mtime>
f f 2019-04-03T08:16:55Z
# grep "git-store-meta.pl" .git/hooks/pre-commit .git/hooks/post-checkout .git/hooks/post-merge
.git/hooks/pre-commit:$(dirname "$0")/git-store-meta.pl --update -d ||
.git/hooks/pre-commit:$(dirname "$0")/git-store-meta.pl --store -d ||
.git/hooks/post-checkout: $(dirname "$0")/git-store-meta.pl --apply -d
.git/hooks/post-merge: $(dirname "$0")/git-store-meta.pl --apply -d
I don't get you. You want the --install
command to create a .git_store_meta
with fields defined by -f
?
If I understand correctly, lozobo proposed to determine the fields to be stored at install time. This is actually a good idea, that should be considered to be extended to the --directory
option.
Because I do not want to hijack this thread, I opened the new issue #21 for that, which is closely related to this one.
If I understand correctly, lozobo proposed to determine the fields to be stored at install time.
Exactly.
#21 seems to be the more generalized approach as we rely on .git_store_meta file rather than generated hooks, and a revise of recorded fields in .git_store_meta no more requires a reinstall of hooks.
I think that also --target
should be handled the same way and be stored in the hook.
Otherwise the hook will always use the default metadata-file instead of the custom one.
--target
for --install
has been implemented as shown above. On the other hand, we prefer --install to be independent to fields used in the metadata file, and therefore we are not going to implement this, as discussed in #21.
I have one doubt left.
The pre-commit hook tries to execute a --update
, but if it fails it will fallback to --store
.
That's good, because it cover the first-run corner case.
The --update
will fail mainly because:
- the metadata-file doesn't exist --> it's the first-run or it was deleted/moved. In both cases, it's ok to recreate it with the installation config.
- can't write on metadata-file for whatever reason -->
--store
will fail either, doesn't matter whatever we do.
The user must run a first ad-hoc --store
, otherwise it will use the default fields.
I think that this can be avoided by just putting --field
only in the --store
execution.
This should not impact any common case scenario, but only the first-run.
What do you think?
Sorry for missing the other thread #22 (comment).
Currently we think that --store is for auto-migration purpose and running it when the metadata store file doesn't exist is pointless, especially when there are multiple branches and some of them doesn't store metadata, and we have added a check to prevent that.