-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
361 lines (338 loc) · 10.8 KB
/
.gitconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
[core]
preloadindex = true
quotepath = off
quotedpath = false
excludesfile = ~/.gitignore.global
pager = ${GIT_PAGER-${PAGER-less}} -FR
[init]
defaultBranch = master
[checkout]
workers = 0
[status]
showUntrackedFiles = normal
[pull]
ff = only
[push]
default = current
[diff]
tool = vimdiff
guitool = smerge
algorithm = histogram
[core]
pager = delta
[interactive]
diffFilter = delta --features=interactive --color-only
[diff]
colorMoved = default # reinterpreted by delta
[delta]
navigate = true
hyperlinks = true
line-numbers = true
# (light|dark) = true # set by ~/bin/util/colorize
# syntax-theme = Solarized-ANSI # reads $BAT_THEME
[merge]
summary = true
conflictstyle = diff3
tool = vimdiff
guitool = smerge
[mergetool "vimdiff"]
layout = LOCAL,BASE,REMOTE / MERGED + BASE,LOCAL + BASE,REMOTE + (LOCAL/BASE/REMOTE),MERGED
[rebase]
autosquash = true
updateRefs = interactive
[blame]
showEmail = true
date = short
coloring = highlightRecent
[rerere]
enabled = 1
autoupdate = true
[clean]
requireForce = false
exclude = /.idea
exclude = /.zed
exclude = /*.sublime-*
exclude = /compile_commands.json
exclude = /.clangd
exclude = /.cache/clangd
exclude = /config.mak
exclude = /config.toml
[gc]
autoDetach = false
reflogExpire = never
reflogExpireUnreachable = never
[pack]
compression = 9
allowPackReuse = "multi"
[sequence]
editor = interactive-rebase-tool
[credential]
helper = /usr/bin/pass-git-helper -l
[sendemail]
annotate = true
[pretty]
# Use a better format for `git refer` (below)
# (aligned with Linux kernel code style)
reference2 = %C(auto)%h (\"%s\")
fixes = %C(auto,green)Fixes: %C(auto)%h (\"%s\")
[alias]
for-each-ref-name = for-each-ref --format '%(refname:short)'
ls-refs = for-each-ref --format '%(refname:short)'
refs = for-each-ref --format '%(refname:short)'
for-each-ref-name-full = for-each-ref --format '%(refname)'
ls-refs-full = for-each-ref --format '%(refname)'
refs-full = for-each-ref --format '%(refname)'
ls-conflicts = diff --name-only --diff-filter=U --relative
cclean = clean -xd -e '/.idea' -e '/*.sublime-*' -e '/compile_commands.json' -e '/.clangd' -e '/.cache/clangd' -e '/config.mak' -e '/config.toml' -e '/.zed'
rebase-i = rebase --rebase-merges=no-rebase-cousins --update-refs --interactive
rebase-ic = rebase --rebase-merges=rebase-cousins --update-refs --interactive
ls-remotev = "!f() { git ls-remote --refs \"$@\" | sort -k2 -V; }; f"
rev = rev-parse --short HEAD
br = symbolic-ref --short HEAD
# aliases do not like being started with `--no-pager` for some reason,
# but `-c` is apparently OK
refer = -c pager.show=false show --no-patch --format=reference2
fixes = -c pager.show=false show --no-patch --format=fixes
copy-refer = "!f() { git refer \"$@\" | clip --copy; }; f"
copy-fixes = "!f() { git fixes \"$@\" | clip --copy; }; f"
copy-ref = "!f() { git rev-parse --verify \"$@\" | clip --copy; }; f"
clone--nolfs = -c filter.lfs.smudge= -c filter.lfs.clean= -c filter.lfs.process='git-lfs filter-process --skip' clone
config-sections = "!f() { \
git config --list --name-only \"${@:2}\" \
| sed -nr \"s|\\.[^.]+$||${1:+\"; /$1/\"}p\" \
| sort -u; \
}; f"
# git-rev-parse, but accepting at most 1 commit
# (without limitations of `git rev-parse --verify`)
rev-parse1 = "!f() { \
shopt -s lastpipe; \
local -a revs; \
git rev-parse \"$@\" | readarray -t revs || return; \
git rev-parse --verify --end-of-options \"${revs[@]}\"; \
}; f"
pick-mr = "!f() { \
mr=\"$1\"; shift; \
mrshort=\"$(git rev-parse --verify --short \"$mr\")\" || return; \
ours=\"$(git rev-parse --verify --short \"$mr^1\")\" || return; \
theirs=\"$(git rev-parse --verify --short \"$mr^2\")\" || return; \
symhead=\"$(git symbolic-ref --short HEAD)\" || symhead=''; \
echo \"Old HEAD: $(git refer HEAD)\"; \
echo \"Merge commit: $(git refer \"$mrshort\")\"; \
echo \" - ours (^1): $(git refer \"$ours\")\"; \
echo \" - theirs (^2): $(git refer \"$theirs\")\"; \
set -x; \
git rebase --onto HEAD \"${mr}^1\" \"${mr}^2\" \"$@\" || { \
{ set +x; } &>/dev/null; \
rc=$?; \
if [[ $symhead ]]; then \
echo >&2 \"Don't forget to update HEAD: \\`git checkout -B $symhead\\`\"; \
fi; \
return $rc; \
}; \
{ set +x; } &>/dev/null; \
echo \"New HEAD: $(git refer HEAD)\"; \
if [[ $symhead ]]; then \
set -x; \
git checkout -B \"$symhead\"; \
{ set +x; } &>/dev/null; \
fi; \
}; f"
pick-range = "!f() { \
start=\"$1\"; end=\"$2\"; shift 2; \
startrev=\"$(git rev-parse --verify --short \"$start\")\" || return; \
fromrev=\"$(git rev-parse --verify --short \"${start}~1\")\" || return; \
endrev=\"$(git rev-parse --verify --short \"$end\")\" || return; \
symhead=\"$(git symbolic-ref --short HEAD)\" || symhead=''; \
echo \"Old HEAD: $(git refer HEAD)\"; \
echo \"From (start~1): $(git refer \"$fromrev\")\"; \
echo \"Start: $(git refer \"$startrev\")\"; \
echo \"End: $(git refer \"$endrev\")\"; \
set -x; \
git rebase --onto HEAD \"$fromrev\" \"$endrev\" \"$@\" || { \
{ set +x; } &>/dev/null; \
rc=$?; \
if [[ $symhead ]]; then \
echo >&2 \"Don't forget to update HEAD: \\`git checkout -B $symhead\\`\"; \
fi; \
return $rc; \
}; \
{ set +x; } &>/dev/null; \
echo \"New HEAD: $(git refer HEAD)\"; \
if [[ $symhead ]]; then \
set -x; \
git checkout -B \"$symhead\"; \
{ set +x; } &>/dev/null; \
fi; \
}; f"
# `git checkout`, but using the first valid ref out of multiple
# arguments prefixed with "+"
zz-tig-checkout = "!f() { \
local -a args refs; \
while (( $# )); do \
if [[ $1 == -- ]]; then \
break; \
elif [[ $1 == +* ]]; then \
if [[ $1 == +?* && ! ${refs+set} ]]; then \
refs+=( \"${1#+}\" ); \
fi; \
else \
args+=( \"$1\" ); \
fi; \
shift; \
done; \
set -x; \
git checkout \"${args[@]}\" \"${refs[@]}\" \"$@\"; \
}; f"
# these abominations exist to fish out a remote name from arguments
# while simultaneously assuming a mostly-reasonable default using
# heuristics (which are included for `git-hub` and `gh` GitHub CLIs)
zz-guess-upstream = "!f() { \
for u; do \
[[ $u != -* ]] && git config \"remote.$u.url\" &>/dev/null && echo \"$u\" && return; \
done; \
git config hub.upstreamremote && return; \
git remote | while IFS='' read -r u; do \
[[ \"$(git config \"remote.$u.gh-resolved\")\" == base ]] && echo \"$u\" && return; \
done; \
for u in upstream origin; do \
git config \"remote.$u.url\" &>/dev/null && echo \"$u\" && return; \
done; \
return 1; \
}; f"
zz-guess-fork = "!f() { \
shopt -s lastpipe; \
for u; do \
[[ $u != -* ]] && git config \"remote.$u.url\" &>/dev/null && echo \"$u\" && return; \
done; \
git config hub.forkremote && return; \
git remote | while IFS='' read -r u; do \
[[ \"$(git config \"remote.$u.gh-resolved\")\" == base ]] && upstream=\"$u\" || forks+=(\"$u\"); \
done; \
[[ ${upstream+set} ]] && (( ${#forks[@]} == 1 )) && echo \"$forks\" && return; \
for u in fork origin; do \
git config \"remote.$u.url\" &>/dev/null && echo \"$u\" && return; \
done; \
return 1; \
}; f"
# this abomination exists for the sole reason of setting a default refspec
# while letting the user control the remote name (which is not possible
# with normal git-push, hence the -c remote.$remote.push dance).
push-work = "!f() { \
remote=\"$(git zz-guess-fork \"$@\")\" || return; \
set -x; \
git -c \"remote.$remote.push=+refs/heads/work/*\" push \"$@\"; \
}; f"
# adapted from https://gist.github.com/gnarf/5406589
pr = "!f() { \
remote=\"$(git zz-guess-upstream \"${@:2:1}\")\" || return; \
prefix=\"pr${2:+\"/$2\"}\"; \
set -x; \
git fetch -fu \"$remote\" \"refs/pull/$1/head:$prefix/$1\" || return; \
git checkout \"$prefix/$1\"; \
}; f"
pr-clean = "!f() { \
[[ ${1+set} ]] && glob=\"$1/*\" || glob=\"**\"; \
git for-each-ref --format 'delete %(refname)' \"refs/heads/pr/$glob\" \
| tee /dev/stderr \
| git update-ref --stdin; \
}; f"
pull-pr = "!f() { \
remote=\"$(git zz-guess-upstream \"${@:2}\")\" || return; \
set -x; \
git pull \"$remote\" \"refs/pull/$1/head\" \"${@:2}\"; \
}; f"
# `pkgctl repo web` but for github
zz-web-pr = "!f() { \
local remote=\"$1\" pull=\"$2\" url; \
url=\"$(git remote get-url \"$remote\")\"; \
case \"$url\" in \
[email protected]:*) url=\"https://github.com/${url#\"[email protected]:\"}\" ;; \
*://github.com:*) url=\"https://github.com/${url#\"*://github.com/\"}\" ;; \
*) echo >&2 "web-pr: unsupported ${remote@Q} URL ${url@Q}"; exit 1 ;; \
esac; \
set -x; \
exec ${BROWSER:-"xdg-open"} \"${url%.git}/pull/${pull}\"; \
}; f"
web-pr--exact = "!f() { \
shopt -s lastpipe; \
local commit; \
commit=\"$(git rev-parse1 --default HEAD \"$@\")\" || exit; \
git for-each-ref \
--points-at \"$commit\" \
--format '%(refname:lstrip=-4)' \
'**/pull/*/head' \
| while IFS=/ read remote _ pull _; do \
git zz-open-pr \"$remote\" \"$pull\" && exit; \
done; \
echo >&2 'web-pr: could not find a PR head at '\"$commit\"; exit 1; \
}; f"
web-pr = "!f() { \
shopt -s lastpipe; \
local commit; \
commit=\"$(git rev-parse1 --default HEAD \"$@\")\" || exit; \
git for-each-ref \
--contains \"$commit\" \
--format '%(ahead-behind:'\"$commit\"') %(refname:lstrip=-4)' \
'**/pull/*/head' \
| awk '$2 == 0 { print $1 \"/\" $3; }' \
| sort -n -t/ -k1 \
| while IFS=/ read n remote _ pull _; do \
git zz-web-pr \"$remote\" \"$pull\" && exit; \
done; \
echo >&2 'web-pr--find: could not find a PR containing '\"$commit\"; exit 1; \
}; f"
recurse = "!f() { \
eval \"$*\" || return; \
git submodule --quiet foreach --recursive \"$*\" || return; \
}; f"
nuke = "!f() { \
git recurse \"git reset --hard && git clean -fxd\" || return; \
git submodule update --init --recursive --progress; \
}; f"
nnuke = "!f() { \
git recurse \"git reset --hard && git cclean\" || return; \
git submodule update --init --recursive --progress; \
}; f"
[color "status"]
header = 10 # "bold green", solarized secondary
added = yellow
changed = green
untracked = cyan
branch = 14 # "bold cyan", solarized emphasis
nobranch = bold black red
unmerged = bold red
[color "blame"]
highlightRecent = 10,6 month ago,normal,1 month ago,bold,1 day ago,yellow
[tig]
mouse = true
mouse-scroll = 1
mouse-wheel-cursor = 1
[gui]
editor = xdg-open
historybrowser = gitg
[guitool "Interactive history rewrite"]
cmd = git rebase -i $REVISION
revprompt = yes
[cola]
tabwidth = 8
textwidth = 80
savewindowsettings = true
linebreak = true
fontdiff = Iosevka Light,10,-1,5,50,0,0,0,0,0
spellcheck = false
safemode = true
boldheaders = true
showpath = true
[svn]
pushmergeinfo = true
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
[include]
path = ~/.gitconfig.private
[include]
path = ~/.gitconfig.machine
[include]
path = ~/.gitconfig.aliases