# local user config, usernames, etc
[include]
    path=~/.config/.gitconfig.local

### git-delta
[core]
    pager = delta
    excludesfile = ~/.config/.gitignore_global
	editor = code --wait
[init]
    defaultBranch = main
[interactive]
    diffFilter = delta --color-only
[delta]
    navigate = true  # use n and N to move between diff sections
    true-color = always
    hyperlinks = true
    hyperlinks-file-link-format = "vscode://file/{path}:{line}"
    # side-by-side = true  # alterantively use git -c delta.side-by-side=true diff
[delta "side-by-side"]
    side-by-side = true
[merge]
    conflictstyle = diff3
[diff]
    colorMoved = default
### end git-delta

[color]
    diff = auto
    status = auto
    branch = auto
    interactive = auto
    ui = auto
[help]
	autocorrect = 1  # Automatically correct and execute mistyped commands.
[branch]
	sort = -committerdate  # Show most recently changed branches first.
[push]
	default = simple
	autoSetupRemote = true
[filter "media"]
	clean = git media clean %f
	smudge = git media smudge %f
	required = true
[alias]
    b = branch
    c = commit
    sw = switch
    swm = switch master
    co = checkout
    com = checkout master
    ss = status
    s = status -s
    ds = diff --staged
    amend = commit --amend -c HEAD
    oops = reset --soft HEAD~1
    kris = pull --rebase
    ignore = !git update-index --assume-unchanged
    unignore = !git update-index --no-assume-unchanged
    ignored = !git ls-files -v | grep "^[[:lower:]]"
    undo = reset --soft HEAD^
    squash = rebase --autostash -i
    megasquash = "!f() { git rebase --autostash -i `git merge-base --fork-point HEAD master`; }; f"
    unstage = restore --staged

    # fzf commands
    cf="!checkout_fzf() { git branch | fzf-tmux -p -h 25% --header 'git checkout' | xargs git checkout; }; checkout_fzf"
    sf="!switch_fzf() { git branch | fzf-tmux -p -h 25% --header 'git switch' | xargs git switch; }; switch_fzf"
    af = "!add_files() { git status -s | awk '{print $2}' | fzf-tmux -m --header 'git add' | xargs git add; }; add_files"
    afc = "!add_files_and_commit() { git status -s | awk '{print $2}' | fzf-tmux -m --header 'git add and commit' | xargs git add && git commit --verbose; }; add_files_and_commit"
    mf = "!merge() { git branch | fzf-tmux -p -h 25% --header 'git merge' | xargs git merge; }; merge"

    # various pretty loggers from various places
    l = log --pretty=oneline --abbrev-commit
    lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative
    lgg = log --graph --pretty=format:'%Creset %s' --abbrev-commit
    lc = log ORIG_HEAD.. --stat --no-merges
    # from http://blog.kfish.org/2010/04/git-lola.html
    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
    ll = log --graph --date=short

    # List contributors with number of commits.
	contributors = shortlog --summary --numbered

    # Show the user email for the current repository.
	whoami = config user.email

    # used for dotbot only
    cleanall = clean -fdx # this is dangerous, so it's intentionally long to type

    update-submodules = submodule update --init --recursive
	upgrade-submodules = submodule update --init --remote

    # Delete all local branches that have been removed from the remote.
	gone = !git fetch --prune && git branch -vv | awk '/: gone]/ {print $1}' | xargs -r git branch -D
