aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvg <vgm+dev@devys.org>2019-11-23 13:19:45 +0100
committervg <vgm+dev@devys.org>2019-11-23 13:19:45 +0100
commitafe5995276527606dc5ed731862a0891a9537a19 (patch)
treeafbe8c12e2d83f071d8c0f278ab4a4da3f107c80
parenta0f6cf9ea9fc0ca36263001a20bf1d0e00987731 (diff)
downloadscripts-afe5995276527606dc5ed731862a0891a9537a19.tar.gz
scripts-afe5995276527606dc5ed731862a0891a9537a19.tar.bz2
scripts-afe5995276527606dc5ed731862a0891a9537a19.zip
new git-sync version failing in case of conflicts
-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