# ~/.gitconfig
# Global Git configuration with multiple identities
# Profile-specific configs are included based on repo location

# ============================================================================
# DEFAULT IDENTITY (fallback)
# ============================================================================
[user]
    name = Kris Yotam
    email = krisyotam@protonmail.com
    signingkey = ~/.ssh/id_ed25519.pub

# ============================================================================
# PROFILE INCLUDES (directory-based identity switching)
# ============================================================================

# Personal projects (krisyotam identity)
[includeIf "gitdir:~/dev/personal/"]
    path = ~/.config/git/profiles/krisyotam

# Pentesting/security projects (khr1st identity)
[includeIf "gitdir:~/dev/security/"]
    path = ~/.config/git/profiles/khr1st

# Work projects (laelyotam identity)
[includeIf "gitdir:~/dev/work/"]
    path = ~/.config/git/profiles/laelyotam

# Dotfiles repo uses personal identity
[includeIf "gitdir:~/dev/krisrice/"]
    path = ~/.config/git/profiles/krisyotam

# ============================================================================
# CORE SETTINGS
# ============================================================================
[core]
    editor = nvim
    pager = delta
    autocrlf = input
    whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol

[init]
    defaultBranch = main

[pull]
    rebase = true

[push]
    default = current
    autoSetupRemote = true

[fetch]
    prune = true

[rebase]
    autoStash = true

# ============================================================================
# DELTA PAGER (Tokyo Night theme)
# ============================================================================
[interactive]
    diffFilter = delta --color-only

[delta]
    navigate = true
    side-by-side = true
    line-numbers = true
    syntax-theme = tokyonight_night
    minus-style = syntax "#3f2d3d"
    minus-non-emph-style = syntax "#3f2d3d"
    minus-emph-style = syntax "#763842"
    minus-empty-line-marker-style = syntax "#3f2d3d"
    line-numbers-minus-style = "#f7768e"
    plus-style = syntax "#283b4d"
    plus-non-emph-style = syntax "#283b4d"
    plus-emph-style = syntax "#316172"
    plus-empty-line-marker-style = syntax "#283b4d"
    line-numbers-plus-style = "#9ece6a"
    line-numbers-zero-style = "#565f89"

# ============================================================================
# DIFF & MERGE
# ============================================================================
[color]
    ui = auto

[merge]
    conflictstyle = diff3
    tool = nvim

[mergetool "nvim"]
    cmd = nvim -d $LOCAL $MERGED $REMOTE

[diff]
    colorMoved = default
    tool = nvim

[difftool "nvim"]
    cmd = nvim -d $LOCAL $REMOTE

# ============================================================================
# COMMIT SIGNING (SSH keys)
# ============================================================================
[commit]
    gpgsign = true

[gpg]
    format = ssh

[gpg "ssh"]
    allowedSignersFile = ~/.config/git/allowed_signers

# ============================================================================
# ALIASES
# ============================================================================
[alias]
    # Status & Info
    st = status -sb
    lg = log --oneline --graph --decorate --all
    ll = log --pretty=format:'%C(yellow)%h%Creset %s %C(cyan)<%an>%Creset %C(green)(%cr)%Creset' --abbrev-commit
    last = log -1 HEAD --stat

    # Branching
    co = checkout
    br = branch -v
    bra = branch -av

    # Committing
    ci = commit
    ca = commit --amend
    can = commit --amend --no-edit

    # Diff
    df = diff
    dfs = diff --staged

    # Stash
    sl = stash list
    sp = stash pop
    ss = stash save

    # Remote
    rv = remote -v

    # Push to all mirrors (uses pushall script or multiple pushurls)
    pa = !git remote | xargs -L1 git push --all
    pushall = !git remote | xargs -L1 git push --all

    # Quick sync
    sync = !git pull --rebase && git push

    # Undo
    unstage = reset HEAD --
    undo = reset --soft HEAD~1

    # Cleanup
    cleanup = !git branch --merged | grep -v '\\*\\|main\\|master' | xargs -n 1 git branch -d

# ============================================================================
# URL SHORTCUTS
# ============================================================================
[url "git@github.com:"]
    insteadOf = gh:

[url "git@git.krisyotam.com:"]
    insteadOf = ky:

[url "git@codeberg.org:"]
    insteadOf = cb:

[url "git@git.sr.ht:"]
    insteadOf = sr:

[url "git@gitlab.com:"]
    insteadOf = gl:
