aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/git-sync
blob: aa1facc169928ac56262530c52a6197f88deaf66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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
if ! git merge --quiet --no-edit; then
    git merge --abort
    exit 1
fi

git push --quiet