[include]
	path = ~/.gitconfig-user

[core]
	; Git sets `$LESS` to `FRX` if it's not already set. `X` disables
	; sending termcap initialization and deinitialization strings to the
	; terminal, which leaves (potentially log) text on the screen and
	; disables mouse scrolling.
	pager = less -+X
	hooksPath      = ~/.githooks
	excludesFile   = ~/.gitignore
	attributesFile = ~/.gitattributes

[init]
	templateDir = ~/.gittemplate
	defaultBranch = master
	; defaultBranch = main

[remote]
	pushDefault = origin

[push]
	default = current
	recurseSubmodules = check

[branch]
	autoSetupMerge  = always
	autoSetupRebase = always

[fetch]
	prune     = true
	pruneTags = true

[rebase]
	autoSquash = true
	autoStash  = true
	updateRefs = true
	missingCommitsCheck = error

[pull]
	rebase = merges

[merge]
	ff = false
	autoStash = true
	conflictStyle = diff3

[am]
	threeWay = true

[rerere]
	enabled = true

[diff]
	renames   = copies
	algorithm = histogram

[url "ssh://git@"]
	pushInsteadOf = https://

[protocol]
	allow = never

[protocol "file"]
	allow = always

[protocol "ssh"]
	allow = always

[protocol "https"]
	allow = always

[transfer]
	fsckObjects = true

[fsck]
	zeroPaddedFilemode = warn
	badTimezone        = warn

[receive "fsck"]
	zeroPaddedFilemode = warn
	badTimezone        = warn

[fetch "fsck"]
	zeroPaddedFilemode = warn
	badTimezone        = warn

[notes]
	rewriteRef = refs/notes/commits

[format]
	notes = true

[status]
	showStash = true
	submoduleSummary = true

[log]
	abbrevCommit = true
	decorate = short

[log]
	date = relative

[blame]
	date = relative

[log]
	graphColors = \
	  BrightRed, \
	  BrightGreen, \
	  BrightYellow, \
	  BrightBlue, \
	  BrightMagenta, \
	  BrightCyan

[diff]
	colorMoved   = zebra
	colorMovedWS = ignore-space-change

[color "diff"]
	meta                      = BrightBlue
	frag                      =       Blue
	func                      =       Blue
	commit                    = BrightYellow
	whitespace                = BrightRed
	plain                     =       Yellow
	context                   = BrightWhite
	contextBold               = BrightWhite
	contextDimmed             =       White
	old                       = BrightRed
	oldBold                   = BrightRed
	oldDimmed                 =       Red
	new                       = BrightGreen
	newBold                   = BrightGreen
	newDimmed                 =       Green
	oldMoved                  = BrightMagenta
	oldMovedDimmed            =       Magenta
	oldMovedAlternative       =       Magenta
	oldMovedAlternativeDimmed =       Magenta
	newMoved                  = BrightCyan
	newMovedDimmed            =       Cyan
	newMovedAlternative       =       Cyan
	newMovedAlternativeDimmed =       Cyan

[blame]
	coloring = repeatedLines
	; coloring = highlightRecent

[color "blame"]
	repeatedLines = White
	highlightRecent = \
	  245, 1  years ago, \
	  246, 6 months ago, \
	  247, 5 months ago, \
	  248, 4 months ago, \
	  249, 3 months ago, \
	  250, 2 months ago, \
	  251, 4  weeks ago, \
	  252, 3  weeks ago, \
	  253, 2  weeks ago, \
	  254, 1  weeks ago, \
	  255

[absorb]
	; https://github.com/tummychow/git-absorb
	maxStack = 100

[pretty]
	patch    =  format:%C(BrightYellow)commit %h%C(auto)%d%n%C(BrightYellow)Author: %aN <%aE>%n%C(BrightYellow)Date:   %ad%n%n%C(Yellow)%s%n
	compact  = tformat:%C(BrightYellow)%h%x20%C(BrightMagenta)%>(13,trunc)%ar%x20%C(BrightBlue)%<(15,trunc)%aN%x20%C(BrightWhite)%s%C(auto)%d
	compactt = tformat:%C(BrightYellow)%h%x09%C(BrightMagenta)%>(1       )%ar%x09%C(BrightBlue)%<(1       )%aN%x09%C(BrightWhite)%s%C(auto)%d

[alias]
	; All.
	all = "!f() { : ; \
	  [ -t 1 ] && terminal=y; \
	  git config --get-colorbool color.all && color_all=always; \
	  git config --get-colorbool color.ui  && color_ui=always; \
	  find . -type d -name '*.git' -prune \
	  | sed 's#^\\./\\.git$\\|^\\./\\|/\\.git$##g' \
	  | sort \
	  | awk '{ \
	    for (parent in parents) \
	      if ($0 ~ \"^\" parent) \
	        next; \
	    parents[$0]; \
	    print; \
	  }' \
	  | { \
	    if [ $# -eq 0 ]; \
	    then \
	      if [ $terminal ]; \
	      then \
	        tree -n ${color_all+-C} --fromfile; \
	      else \
	        cat; \
	      fi; \
	    else \
	      if [ $color_all ]; \
	      then \
	        get_color() { git -C \"$path\" config --get-color \"$@\"; }; \
	        color_reset=$(get_color '' reset); \
	        color_all_header=$(get_color color.all.header yellow); \
	      fi; \
	      while read -r path; \
	      do \
	        output=$(git -C \"$path\" -c color.ui=$color_ui \"$@\" 2>&1); \
	        [ \"$output\" ] || continue; \
	        printf '%s%s%s\\n%s\\n\\n' \
	          \"$color_all_header\" \
	          \"$path\" \
	          \"$color_reset\" \
	          \"$output\"; \
	      done; \
	    fi; \
	  } \
	  | eval \"LESS=${LESS-FRX} $(git var GIT_PAGER)\"; \
	}; f"

	; Tree.
	tree = "!f() { : git ls-files ; \
	  git config --get-colorbool color.tree && color_tree=always; \
	  git ls-files \"$@\" | tree -n ${color_tree+-C} --fromfile; \
	}; f"

	; Users.
	users = "!f() { : git log ; \
	  git log --pretty=full \"$@\" \
	  | sed -n 's/^\\(Author\\|Commit\\): \\(.*\\)/\\2/p' \
	  | sort -u; \
	}; f"

	; Browse.
	browse ="!f() { : ; \
	  set --; \
	  urls=\"$(git remote get-url ${@:-$(git remote)})\"; \
	  for url in $urls; \
	  do \
	    echo $url; \
	    { [ $(command -v xdg-open) ] && xdg-open \"$url\"; } || \
	    { [ $(command -v open)     ] && open     \"$url\"; } || \
	    { [ $(command -v start)    ] && start    \"$url\"; } || \
	    echo \"$@\"; \
	  done; \
	}; f"

	; Refdiff.
	refdiff = "!f() { : git diff ; \
	  git config --get-colorbool color.diff && color_diff=always; \
	  git reflog --pretty='format:%h: %gs' \
	  | awk -F': ' '$2~/(commit|rebase).*\\((amend|finish)\\)/{print $1}' \
	  | while read -r ref; \
	  do \
	    git -c color.diff=$color_diff show --no-patch $ref; \
	    echo; \
	    git -c color.diff=$color_diff diff \"$@\" $ref HEAD; \
	    echo; \
	  done \
	  | eval \"LESS=${LESS-FRX} $(git var GIT_PAGER)\"; \
	}; f"

	; Filter meta.
	filter-meta = "!f() { : git filter-branch ; \
	  name=\"$1\";  shift; \
	  email=\"$1\"; shift; \
	  git filter-branch \"$@\" --env-filter \" \
	    GIT_AUTHOR_NAME=\\\"$name\\\"; \
	    GIT_AUTHOR_EMAIL=\\\"$email\\\"; \
	    GIT_COMMITTER_NAME=\\\"$name\\\"; \
	    GIT_COMMITTER_EMAIL=\\\"$email\\\"; \
	    GIT_COMMITTER_DATE=\\\"\\$GIT_AUTHOR_DATE\\\"; \
	  \" ; \
	}; f"

	; Log.
	l = "!f() { : git log ; \
	  git config --get-colorbool color.diff && color_diff=always; \
	  git -c color.diff=$color_diff log --graph --pretty=compactt \"$@\" \
	  | sed -E 's/^([^\\t]+\\t[^\\t,]+)(,.+)? ago(.*\\t.*)$/\\1\\3/' \
	  | sed -E 's/^(.*) +(.*[0-9a-f]{7}.*\\t)/\\1\\t\\2/' \
	  | sed -E 's/ *$//' \
	  | column -t -o ' ' -s \"$(printf '\\t')\" \
	  | eval \"LESS=${LESS-FRX} $(git var GIT_PAGER)\"; \
	}; f"
	ls = log --oneline --decorate=no
	lf = log --first-parent
	lp = log --patch --pretty=patch
	lpw  = lp --color-words='[_[:alnum:]]+|[^[:space:]]'
	lpww = lp --color-words='.'
	la    = l    --all
	lsa   = ls   --all
	lfa   = lf   --all
	lpa   = lp   --all
	lpwa  = lpw  --all
	lpwwa = lpww --all

	; Status.
	s  = status
	ss = status --short
	sb = status --short --branch
	sa  = s  --ignored
	ssa = ss --ignored
	sba = sb --ignored

	; Diff.
	d  = diff
	du = diff @{upstream}
	dp = diff @{push}
	dc  = d  --cached
	duc = du --cached
	dpc = dp --cached
	dw   = d   --color-words='[_[:alnum:]]+|[^[:space:]]'
	duw  = du  --color-words='[_[:alnum:]]+|[^[:space:]]'
	dpw  = dp  --color-words='[_[:alnum:]]+|[^[:space:]]'
	dcw  = dc  --color-words='[_[:alnum:]]+|[^[:space:]]'
	ducw = duc --color-words='[_[:alnum:]]+|[^[:space:]]'
	dpcw = dpc --color-words='[_[:alnum:]]+|[^[:space:]]'
	dww   = d   --color-words='.'
	duww  = du  --color-words='.'
	dpww  = dp  --color-words='.'
	dcww  = dc  --color-words='.'
	ducww = duc --color-words='.'
	dpcww = dpc --color-words='.'

	; Add.
	au = add -u
	aa = add -A

	; Commit.
	c  = commit
	ca = commit --amend

	; Rebase.
	ri = rebase -i
	ro = rebase -i --root
	rr = rebase --continue

	; Fetch.
	f = fetch

	; Push.
	p  = push
	pf = push --force-with-lease

	; Clean ignored files (requires either `-f`, `-i` or `-n`).
	x = clean -Xd

	; Contains.
	contains = tag --contains
	; contains = describe --contains