summaryrefslogtreecommitdiff
path: root/doc/special_remotes/hook.mdwn
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-05-21 19:19:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-05-21 19:19:03 -0400
commit83b31b8c2a68a96d1ef02ac8714b0e7ad5ce25ad (patch)
tree2d8e31f266627fcf9d4fdb9793261ed07ddd33af /doc/special_remotes/hook.mdwn
parentb6ebb173e7b5d4d07577cb2918e7d1a24fbc1f60 (diff)
hook special remote: Added combined hook program support.
Diffstat (limited to 'doc/special_remotes/hook.mdwn')
-rw-r--r--doc/special_remotes/hook.mdwn37
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
+"""]]