# vim: ft=gitconfig:noet:sw=8:sts=8:fdm=indent
[alias]
	amend = commit --amend
	b = branch -vv
	bd = branch --delete
	bdesc = !git -c core.editor=cat branch --edit-description | git stripspace -s
	bdf = branch --delete --force
	bed = branch --edit-description
	blame-more = blame -w -CCC -M
	bv = branch -vva
	ca = commit --all
	cc = commit
	cce = !git commit --edit --file="$(git rev-parse --git-dir)"/COMMIT_EDITMSG
	ce = config --edit
	changed = diff --name-only
	cm = commit --message
	co = checkout
	conflict = graph --left-right --boundary --merge
	cp = cherry-pick
	ctags = hook run ctags
	d = diff
	dc = diff --cached
	ds = diff --stat
	f = fetch
	g = !exec git
	git = !exec git
	grall = graph --all
	graph = graph-long --oneline
	graph-long = log --graph
	h = help
	ig = check-ignore
	igv = ig --verbose
	intend = add --intent-to-add
	j = jump
	list-all-objects = cat-file --batch-check --batch-all-objects --unordered
	logp = log --graph --abbrev-commit --pretty=mine
	logpall = logp --all
	lol = log --oneline
	merc = merge --no-ff
	merf = merge --ff-only
	name-when-merged = "!f() { git when-merged -c \"$@\" | git name-rev --annotate-stdin;}; f"
	newb = switch -c
	patch = add --patch
	pf = push --force-with-lease
	r = rebase
	rc = rebase --continue
	rdup = range-diff @{upstream} @{push} @
	rdupc = !git rdup | copy-range-diff
	remerf = "!f() { git rebase \"$1\" \"$2\"; git checkout \"$1\"; git merge --ff-only \"$2\"; }; f"
	rems = for-each-ref --sort=-committerdate --format=\"%(refname:short)\t%(color:red)%(authorname)\t%(color:blue)%(authordate:relative)%(color:reset)\" refs/remotes
	ri = rebase --interactive
	rs = rebase --autosquash
	s = status --short
	sb = show-branch
	sbu = sb HEAD HEAD@{upstream}
	sbup = sbu HEAD@{push}
	sdiff = diff && git submodule foreach 'git diff'
	spush = push --recurse-submodules=on-demand
	sr = status --short --branch
	standup = "!f() { git log --author=$USER --since=yesterday --all --format=%s; }; f"
	stat = status
	supdate = submodule update --remote --checkout
	tags = tag --list
	tagss = "!f() { git tags \"$@\" | xargs git show; }; f"
	unstage = reset HEAD --
	visual = !gitk --all &

# core
[core]
	excludesFile = ~/.gitignore_global
	attributesFile = ~/.gitattributes
	pager = less -FRX
	commentChar = ";"
[init]
	templateDir = ~/.git_template
	defaultBranch = main
[help]
	autocorrect = prompt

# remotes
[fetch]
	recurseSubmodules = on-demand
	prune = true
	writeCommitGraph = true
	parallel = 0
	all = true
[push]
	recurseSubmodules = check
	useForceIfIncludes = true
	default = current
[pull]
	rebase = merges
[submodule]
	fetchJobs = 4
	recurse = true

[tag]
	sort = -version:refname

# global branch options
[branch]
	autoSetupRebase = always
	sort = -committerdate
	sort = -HEAD

# diffs and merges
[diff]
	algorithm = histogram
	submodule = log
	tool = vimdiff
	colorMoved = default
	mnemonicprefix = true
[diff "json"]
	textconv = "f(){ gron \"$1\" 2>/dev/null || cat \"$1\"; }; f"
[diff "yq"]
	textconv = "f(){ yq -P eval 'sort_keys(..)' \"$1\" 2>/dev/null || cat \"$1\"; }; f"
[diff "csv"]
	textconv = "f() { mlr --csv cat \"$1\" || true; }; f"
[difftool]
	prompt = no
[merge]
	tool = fugitive
	conflictstyle = zdiff3
	log = true
[mergetool]
	prompt = no
	keepBackup = false
[mergetool "fugitive"]
	cmd = vim --nofork +\"Git mergetool -- $MERGED\" +cclose
	trustExitCode = true
[rerere]
	enabled = true
[blame]
	markUnblamableLines = true
	markIgnoredLines = true

# interface
[grep]
	lineNumber = true
	column = true
[rebase]
	autoSquash = true
	autoStash = true
	updateRefs = true
[status]
	submodulesummary = 1
	showstash = true
[sendemail]
	multiedit = true
	annotate = true
	confirm = auto
[format]
	coverLetter = auto
	coverFromDescription = auto
	useAutoBase = whenAble
	notes = true
[trailer "t"]
	cmd = git-find-ticket

# external: lfs
[filter "lfs"]
	clean = git-lfs clean -- %f
	smudge = git-lfs smudge -- %f
	process = git-lfs filter-process
	required = true

# external: gitsh
[gitsh]
	prompt = "%D (%c%b %#%w) %G>"
	noGreeting = true
	defaultCommand = status -s
[gitsh "color"]
	default = cyan

# user config
[user]
	useConfigOnly = true

# includes
[include]
	path = ~/.gitconfig.local
