gi.def

# GIT

# ---------------------------------------------------------------------------------------
= GENERAL
# ---------------------------------------------------------------------------------------

add commit push (acp) [<-f|--force>] [<message>] :: \
    force_yn=n; \
    if [[ $1 == -f || $1 == --force ]]; then \
        force_yn=y; \
        shift; \
    fi; \
    if [[ "$1" == "" ]]; then \
        message="Various"; \
    else \
        message="$1"; \
    fi; \
    [ -f ./gen-readme ] && ./gen-readme; \
    git add .; \
    git status; \
    if [[ "$1" != "-f" ]]; then \
        read -p 'Press a key to continue, CTRL-C to abort' dummy; \
    fi; \
    git commit -m 'Various'; \
    git push origin

list branches local (lbl) :: \
    git branch

list branches remote (lbr) :: \
    git branch -r

clone (c) <url> :: \
    git clone $1

fetch (f) :: git fetch

history (h) :: \
    git log > /tmp/gi1; \
    while read line; do echo $line; \ 
        if [[ ${line:0:6} == commit ]]; then \
            git diff-tree --no-commit-id --name-only -r ${line:7:99} | \
            tr "\n" " " | fold -s -w 100; echo; \
        fi; \
    done < /tmp/gi1 | \
    sed "s/^  *//; /^$/d; s/^commit/${l80}\n${c_yel}Commit:/" | \
    sed "s/^Author/${c_lcya}Author/; s/^Date/${c_lgre}Date/; s/$/${c_whi}/"; \
    rm -f /tmp/gi1 /tmp/gi2

pull (pu) :: \
    git pull

push origin (po) :: \
    git push origin

status (s) :: git status

switch branch (sb) <branch-name> :: \
    git checkout $1 ## (git checkout)