[user]
    name = Mathieu Maret
    email = mathieu.maret@gmail.com
[color]
    ui = auto
    diff = auto
    status = auto
    branch = auto
[pack]
    threads = 0
[alias]
    st = status
    ci = commit
    cia = commit --amend
    cias = commit --amend --no-edit
    co = checkout
    br = branch
    df = diff
    dc = diff --cached
    lg = log -p
    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
    lolp = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
    ls = ls-files
    dt = difftool # to have diff with meld
    mylog = log --committer=\"$(git config user.name)\"
    please = push --force-with-lease
#   Remove last commit but keep changes
    undo = reset --soft HEAD^
    revertpart = reset -p HEAD^
    diffword = diff --color-words=.
    save = stash save -u
#rebase last N commits
    rb = "!f() { git rebase -i HEAD~$1; }; f"
#rebase since branching on branch N
    rbi = !sh -c \"git rebase -i `git merge-base $1 HEAD`\" -
    cleanbr = remote prune origin
    cleanbrshow = remote prune origin --dry-run
    cleanupbr = "!git branch --merged | grep  -v '\\*\\|master\\|develop\\|dev' | xargs -n 1 git branch -d"
    cleanupbrprune = "!git fetch --prune"
    contains = !sh -c 'git branch -a --contains $1' -
    wdiff = diff --word-diff=color --unified=1
    first = rev-list --max-parents=0 HEAD # or use log --reverse
    rebasestash = rebase --autostash # stash before rebase if needed
#Gitlab checkout merge request. e.g. get MR 5 on remote upstream git mr upstream 5
    mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
#Git reset upstream
    ru = "!f() { \
        REMOTES=$(git remote); \
        REMOTE=\"origin\"; \
        case \"$REMOTES\" in \
            *upstream*) \
                REMOTE=\"upstream\"; \
            ;; \
        esac; \
        git fetch $REMOTE; \
        git update-ref refs/heads/master refs/remotes/$REMOTE/master; \
        git checkout master >/dev/null 2>&1; \
        git reset --hard $REMOTE/master >/dev/null 2>&1; \
        git checkout - >/dev/null 2>&1; \
        }; f"
    code-changes = "!git log --format=format: --name-only | egrep -v '^$' | sort | uniq -c | sort -rg | head -10"
    cc = "!git code-changes"
    fixup = "commit --fixup"
    ri = "rebase -i --autosquash"
[branch]
    #New branch track remote
    #autosetupmerge = always
    # Rebase on git pull
    #autosetuprebase = always

# in .gitattributes
# *.doc diff=word
# *.xsl diff=excel
# *.xlsx diff=zip
# *.docx diff=wordx
# *.png diff=exif

[diff "odf"]
    textconv=odt2txt
[diff "odt"]
    textconv=odt2txt
[diff "pandoc"]
    textconv=pandoc --to=markdown
    prompt = false
[diff "wordx"]
    textconv = docx2txt_wrap
[diff "word"]
    textconv = catdoc
[diff "excel"]
    textconv = strings
[diff "zip"]
    textconv = unzip -c -a
[diff "exif"]
    textconv = exiftool
[difftool "meld"]
    path = /usr/bin/meld
    trustExitCode = false
[difftool]
    prompt = false
[diff]
    tool = meld
    compactionHeuristic = true
[mergetool "meld"]
    path = /usr/bin/meld
    trustExitCode = false
[mergetool]
    # do not keep .ori file after a merge
    keepBackup = false
[merge]
    tool = meld
#    tool = vimdiff
#    conflictstyle = diff3
[push]
    default = current #push to upstreal assuming same name for the upstream and current branch
    #default = upstream # pushed to the configuer upstream branch
[credential]
	helper = cache --timeout=3600
[sendemail]
	from = Mathieu Maret <mathieu.maret@gmail.com>
	smtpserver = smtp.gmail.com
	smtpuser = mathieu.maret
	smtpencryption = tls
	smtpserverport = 587
#	smtppass = PASS
[web]
	browser = firefox

[rerere]
	enabled = true
[pager]
	log = /usr/share/git/diff-highlight/diff-highlight | less
	show = /usr/share/git/diff-highlight/diff-highlight | less
	diff = /usr/share/git/diff-highlight/diff-highlight | less
[interactive]
	diffFilter = /usr/share/git/diff-highlight/diff-highlight
[filter "lfs"]
	required = true
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
[pull]
	rebase = true