~miconoco/woo

woo/bin/pull -rwxr-xr-x 705 bytes
0b1818b1Christoph Polcin build 3 months ago
                                                                                
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
33
#!/bin/sh
# pull
#   Pulls changes from remote.

set -e

git status --short --branch --ahead-behind

printf '\n'

hash0="$(git rev-parse --short HEAD^ || git rev-parse --short HEAD)"

if git status -sb --porcelain \
    | grep -v '^??' \
    | grep -v '^#.*\[\(behind\|gone\)' \
    | grep -q '^\([^#]\|#.*[^\]]$\)'
then
    git remote update >/dev/null 2>&1
    hash1="$(git for-each-ref --format='%(upstream:short)' \
        "$(git symbolic-ref -q HEAD)")"
else
    git pull --quiet
    hash1=""
fi

git --no-pager \
    log \
    --oneline \
    --pretty=format:'%C(blue)%h  %C(reset)%s %C(green)[%cr] %C(dim white)<%aE>%C(reset)%n%w(0,4,4)%-b%n%n%-N' \
    "${hash0}..${hash1}" \
    --

printf '\n'