summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorJoey Hess2016-03-07 18:40:24 -0400
committerJoey Hess2016-03-07 20:17:18 -0400
commit0daf924b43d0750b285a5e857eb9946a9a71e6cc (patch)
treea5ac2c8aa1464daa7c2649772242d466485935e2 /contrib
parentad4323859caea503114df40bde0f6b273441e6d2 (diff)
privdata/relocate
better than symlinks because this way no conflict can ever occur and, commit from hook
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/post-checkout-hook28
-rwxr-xr-xcontrib/post-merge-hook44
2 files changed, 44 insertions, 28 deletions
diff --git a/contrib/post-checkout-hook b/contrib/post-checkout-hook
deleted file mode 100755
index 38998398..00000000
--- a/contrib/post-checkout-hook
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/bin/sh
-#
-# git post-checkout hook, used by propellor's author to maintain a
-# joeyconfig branch where config.hs is a symlink to joeyconfig.hs
-#
-# Each time this hook is run, it checks if it's on a branch with
-# name ending in "config". If so, config.hs is pointed at $branch.hs
-# Otherwise, config.hs is pointed at config-simple.hs
-#
-
-set -e
-prevhead="$1"
-newhead="$2"
-branchcheckout="$3"
-if [ "$branchcheckout" != 0 ]; then
- branch="$(git symbolic-ref --short HEAD)"
- case "$branch" in
- "")
- true
- ;;
- *config)
- ln -sf "$branch".hs config.hs
- ;;
- *)
- ln -sf config-simple.hs config.hs
- ;;
- esac
-fi
diff --git a/contrib/post-merge-hook b/contrib/post-merge-hook
new file mode 100755
index 00000000..fa9ab5b6
--- /dev/null
+++ b/contrib/post-merge-hook
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# git post-merge hook, used by propellor's author to maintain a
+# joeyconfig branch with some changes while being able to merge
+# between it and branches without the changes.
+#
+# Each time this hook is run, it checks if it's on a branch with
+# name ending in "config". If so, config.hs is pointed at $branch.hs
+# and privdata/relocate is written to make files in privdata/.$branch/ be
+# used.
+#
+# Otherwise, config.hs is pointed at config-simple.hs, and
+# privdata/relocate is removed.
+
+set -e
+
+commit () {
+ if [ -n "$(git status --short privdata/relocate config.hs)" ]; then
+ git commit privdata/relocate config.hs -m "$1"
+ fi
+}
+
+branch="$(git symbolic-ref --short HEAD)"
+case "$branch" in
+ "")
+ true
+ ;;
+ *config)
+ ln -sf "$branch".hs config.hs
+ git add config.hs
+ echo ".$branch" > privdata/relocate
+ git add privdata/relocate
+ commit "setting up $branch after merge"
+ ;;
+ *)
+ ln -sf config-simple.hs config.hs
+ git add config.hs
+ if [ -e privdata/relocate ]; then
+ rm -f privdata/relocate
+ git rm --quiet privdata/relocate
+ fi
+ commit "clean up after merge"
+ ;;
+esac