[color]
ui = auto
diff = auto
branch = auto
status = auto
branch = auto
interactive = auto

[core]
    editor = geany
    quotepath = false
    hooksPath = .githooks

[giggle]
    main-window-maximized = true
    main-window-geometry = 0x0+0+0
    history-view-vpane-position = 451
    file-view-vpane-position = 724
    main-window-view = HistoryView

[user]
    email = ferryjeremie@free.fr
    name = Ferry Jérémie

[diff]
    mnemonicPrefix = true
    wordRegex = .

[fetch]
    recurseSubmodules = on-demand

[grep]
    extendedRegexp = true

[log]
    abbrevCommit = true

[alias]
    a  = add
    ad = add

    c  = commit
    ci = commit

    s  = status -sb
    st = status -sb

    sw = switch

    f  = fetch
    d  = diff
    t  = tag

    co = checkout
    ck = checkout
    ch = checkout

    b  = branch
    br = branch

    create = switch --create

    m = merge

    pl = pull

    ps = push
    psh = push

    cp = cherry-pick

    lastbranches= !sh -c 'git branch -v --sort=committerdate | head -n 10'

    push = "push --recurse-submodules=on-demand"

    prev = checkout HEAD^1
    next = "!sh -c 'git log --reverse --pretty=%H master | awk \"/$(git rev-parse HEAD)/{getline;print}\" | xargs git checkout'"
    last = "!sh -c 'git checkout $(git describe --tags $(git rev-list --tags --max-count=1))'";

    ### logs
    l = log --pretty=format:'%C(yellow)%h %C(blue)%an %C(green)%ad %Creset%s'
    lg = log --oneline --graph --decorate -n 50
    ll = "log --graph --pretty=format:'%C(yellow)%h %C(blue)%ci%C(green) %an %C(red)%d %Creset%s'"
    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all

    lg1 = log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all

    lg2 = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

    lfile = l --follow --max-count=20 --cherry-pick

    show-tree = log --all --graph --decorate --oneline --simplify-by-decoration

    ### blame
    # count the number of lines attributed to each author
    b-nb = "!sh -c 'git blame --line-porcelain $0 $@ | sed -n \"s/^author //p\" | sort | uniq -c | sort -rn'"

    ### better diff
    diffc = diff --cached
    difff = diff --color-words=. -w
    # diff on submodules
    sdiff = "!sh -c 'git diff && git submodule foreach \"git diff\"'"
    # better diff with submodules
    sdifff = "!sh -c 'git difff && git submodule foreach \"git difff\"'"
    # difff = diff --word-diff=color --ignore-space-change
    # vdiff = "difftool --tool=vimdiff"

    ### explications : http://blog.octo.com/git-dans-la-pratique-12/
    lpush = "!git --no-pager log origin/$(git currentbranch)..HEAD --oneline"
    lpull = "!git --no-pager log HEAD..origin/$(git currentbranch) --oneline"
    whatsnew = "!git diff origin/$(git currentbranch)...HEAD"
    whatscoming = "!git diff HEAD...origin/$(git currentbranch)"
    currentbranch = "!git branch | grep \"^\\*\" | cut -d \" \" -f 2"


    #############
    whois = "!sh -c 'git log -i -1 --pretty=\"format:%an <%ae>\n\" --author=\"$1\"' -"
    whatis = show -s --pretty='tformat:%h (%s, %ad)' --date=short
    #############
    human = name-rev --name-only --refs=refs/heads/*

    root = rev-parse --show-toplevel
    exec = "!exec "
    cstatus = -c color.status=always status --short
    bc = branch --color -v

    submodules = submodule foreach git pull --all
    pullall = "!sh -c 'test -n $(git root) && cd $(git root) && git pull --all && git submodule foreach git pull --all'"
    pullall = "!sh -c 'test -n $(git root) && cd $(git root) && git push --all && git submodule foreach git push --all'"

    adduamend = "!sh -c 'git add -u && git c --amend --no-edit'"
    addaamend = "!sh -c 'git add -A && git c --amend --no-edit'"

[pull]
    rebase = true

[init]
    defaultBranch = main