aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xscripts/git-sync27
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/git-sync b/scripts/git-sync
new file mode 100755
index 0000000..a9f07ac
--- /dev/null
+++ b/scripts/git-sync
@@ -0,0 +1,27 @@
+#!/bin/bash
+set -eu
+
+if [ -d "$(git rev-parse --git-dir)/annex" ]; then
+ echo 'Sync: using git annex'
+ exec git annex sync "$@"
+ exit 1 # if attained, this is an error
+fi
+
+branch_name=$(git symbolic-ref -q --short HEAD)
+
+if [ "$(git config --get --bool branch.${branch_name}.sync)" != "true" ]; then
+ echo "Branch is not configured to accept git-sync, maybe you can do:" >&2
+ echo " git config --bool branch.${branch_name}.sync true" >&2
+ exit 1
+fi
+
+git fetch --all --quiet
+
+git add -A "./$(git rev-parse --show-cdup)"
+if ! git diff --cached --quiet; then
+ git status --short
+ git commit -m "git-sync on ${HOSTNAME}"
+fi
+
+git merge --ff-only
+git push --quiet