diff options
Diffstat (limited to 'doc/special_remotes/hook.mdwn')
-rw-r--r-- | doc/special_remotes/hook.mdwn | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/doc/special_remotes/hook.mdwn b/doc/special_remotes/hook.mdwn index d17fae4c8..ecfb8a7dc 100644 --- a/doc/special_remotes/hook.mdwn +++ b/doc/special_remotes/hook.mdwn @@ -50,7 +50,7 @@ These environment variables are used to communicate with the hook commands: into 1024 buckets. * `ANNEX_HASH_2` - another hash value, can be used for a second level of hashing -The setting to use in git config for the hook commands are as follows: +The settings to use in git config for the hook commands are as follows: * `annex.$hooktype-store-hook` - Command run to store a key in the special remote. `ANNEX_FILE` contains the content to be stored. @@ -68,3 +68,38 @@ The setting to use in git config for the hook commands are as follows: if and only if the key has been actively verified to be present in the special remote (caching presence information is a very bad idea); all other output to stdout will be ignored. + +## combined hook program + +Rather than setting all of the above hooks, you can write a single +program that handles everything, and set a single hook to make it be used. + + # git config annex.demo-hook /usr/local/bin/annexdemo + # git annex initremote mydemorepo type=hook hooktype=demo encryption=none + +The program just needs to look at the `ANNEX_ACTION` environment variable +to see what it's being asked to do For example: + +[[!format sh """ +#!/bin/sh +set -e +case "$ANNEX_ACTION" in + store) + demo-upload "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY" < "$ANNEX_FILE" + ;; + retrieve) + demo-download "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY" > "$ANNEX_FILE" + ;; + remove) + demo-nuke "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY" + ;; + checkpresent) + if demo-exists "$ANNEX_HASH_1/$ANNEX_HASH_2/$ANNEX_KEY"; then + echo "$ANNEX_KEY" + fi + *) + echo "unkown ANNEX_ACTION: $ANNEX_ACTION" >&2 + exit 1 + ;; +esac +"""]] |