Fossil User Forum

Possible typo in www/hooks.md
Login

Possible typo in www/hooks.md

Possible typo in www/hooks.md

(1) By BPK (bpk000) on 2025-01-23 21:40:01 [link] [source]

On the Hooks documentation page, under Before-Commit Hooks, the second bullet currently reads:

The %A substitution is the name of a "commit description file" that shows the details of the commit in progress. To see what a "commit description file" looks like, set a before-commit hook with a command of "cat %Q" and then run a sample commit with the --dry-run option.

I don't think there is a %Q substitution as noted in "cat %Q" above. I don't see any other reference to it on the page and when I test it, nothing gets substituted. Based on context, it seems that "cat %Q" should be "cat %A" for the auxiliary input file.

Thanks again! I've been trying to get familiar with hooks so going through the help and docs.

(2) By brickviking on 2025-01-28 21:45:56 in reply to 1 [source]

That seems to be correct, you do need %A, and not %Q. I'll have a patch in for that momentarily; I had to mentally unwind how the before-commit hook translates input variables.

I found an easier way to test the hooks by using fossil hook test ... for the hook created with before-commit as a type.

fossil hook add --command "cat %A" --type before-commit --sequence 1

When using %Q, and fossil hook test --dry-run 0 (in the case where the hook was newly created and no other hooks added), fossil complains:

~/src/fossil$ fossil hook test --aux-file "README.md"  0 # an example file to be catted
cat: %Q: No such file or directory

Thanks for reporting that.

Cheers, RTDoc brickviking
(Post 61)