-
Notifications
You must be signed in to change notification settings - Fork 1
/
dot.gitconfig
521 lines (490 loc) · 19.7 KB
/
dot.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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# -*- conf -*-
# For host-specific customization create a ~/.gitconfig.system-custom
# file.
# Best git tutorial I've read:
# http://newartisans.com/2008/04/git-from-the-bottom-up/
# http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
[user]
name = Nathan Collins
email = nathan.collins@gmail.com
[apply]
whitespace = fix
[core]
# Global excludes file that applies to all repos. The default value
# is '$XDG_CONFIG_HOME/git/ignore', which in turn defaults to
# '~/.config/git/ignore'.
#
# There is also '.git/info/exclude', which is a per repo, but
# unversioned gitignore file. See 'man gitignore'.
excludesFile = ~/.gitignore
# Apparently git sets 'LESS=FRSX'. The 'F' means to quit if output
# fits on one screen, the 'R' means to interpret escapes (e.g. ANSI
# color), the 'S' means to chop long lines, and the 'X' means not to
# clear the screen after leaving 'less'. Below, the 'M' means to
# show a detailed status line, and the 'i' means to ignore case in
# searches. The '+Gg' means read the whole file (so that the
# percentage can be computed).
#
# See http://stackoverflow.com/a/19871578/470844.
#
#pager = less -Mi +Gg
#
# Turns out that is annoying for short output: the whole screen gets
# filled with tildes (using '--tilde' makes them disappear, but the
# whole screen is still full).
#
# Unrelated: because my prompt is multiple lines (usually 2; 3 when
# in a repo), the trick where 'less' exits if the output fits on one
# screen does not work correctly. Looking at 'man less', I would
# think that setting 'LINES' would help, but it does not. The man
# page mentions that 'TIOCGWINSZ' or 'WIOCGETD' take precedence if
# supported (no idea what these are), so that must be the problem.
#
# This Stack Exchange question is helpful:
# http://unix.stackexchange.com/questions/93173/how-does-less-know-the-terminal-resolution
#
# Using 'stty rows <n>' to set the number of rows to 'n' caused
# other problems.
#
# So just disable '-F' and have to hit 'q' a little more often.
#
# The good solution is probably to use a simple preprocessor that
# only invokes 'less' if the output is longer than the specified
# number of lines. The "specified number of lines" can then be
# calculated based on the size of the prompt. After all, changing
# the terminal height setting to an incorrect value confuses less
# with good reason. As a bonus, using this preprocessor would mean
# that the tilde problem when using '+Gg' described above would also
# go away.
pager = less -Mi -+F
# Line ending normalization: see
# http://timclem.wordpress.com/2012/03/01/mind-the-end-of-your-line/
#
# Apparently git-svn is buggy when it comes to
# svn:eol-style=native: git does not perform any translation in
# the working copy when this attribute is set, and doesn't convert
# line endings to LF before committing when this attribute is set.
# Together, these mean that you can git-svn commit a file with
# CRLF line endings, while setting the svn:eol-style=native
# attribute via ~/.subversion/config (which git-svn honors),
# without actually changing the CRLF to LF in the committed file.
# The end result is that the subversion repo will store the file
# with CRLF line endings, even though svn:eol-style=native is
# supposed to mean that the file is stored with native line
# endings (since setting this attribute in a subversion working
# copy automatically causes the files line endings to be
# converted). When you check the file out in git again, git will
# leave the CRLF line endings in tact :P And maybe worse,
# subversion will convert them on checkout, but then any edits
# will result in the full file being marked as changed :P
#
# I didn't find any nice
# make-git-do-the-subversion-style-conversion solution, but by
# setting autorclf = input and safecrlf = warn (warn might be the
# default), you can have git convert CRLF to LF *before*
# committing, and warn you about it. This doesn't help with
# already screwed up files, but it will hopefully stop me from
# accidentally committing CRLF files in the future.
#
# The 'eol' setting controls what line endings you get in the
# working copy, but the default value of 'native' doesn't help
# with the above problem, and changing it to 'lf' to force LF
# marks all files with CRLF as modified :P
# Solution: see http://stackoverflow.com/a/10762396/470844
# Subsumed by ~/.gitattributes.
#
# autocrlf = input
# Warn when line endings are converted. Default?
safecrlf = warn
# Convert files with the 'text' attribute to native line endings
# on checkout (Default).
#
# eol = native
# File containing global git attributes. See 'git help
# attributes'. I'm setting '* text=auto' there, which subsumes
# 'core.autocrlf=input'.
#
# To override this in a repo that already has files with messed up
# line endings, create a .gitattributes (or .git/info/attributes)
# in the repo with contents
#
# * text=unspecified
#
# or just use 'nc:git:disable-whitespace-conversion*'.
attributesfile = ~/.gitattributes
# Turn this on temporarily if git(-svn) gets confused by an
# symlink that is actually a file. Then commit the file. Then
# turn this off again and commit the file again, which registers a
# "typechange".
#
#symlinks = false
# I can't figure out how to stop emacs's vc-git from setting
# fundamental-mode and ruining flyspell ... so, i added
# fundamental-mode to my auto flyspell-mode modes, in
# extensions/flyspell.el.
#
# UPDATE: now git has also learned to set default-generic-mode in
# some cases ??? So, updated auto flyspell-mode modes to include
# that ... this is obviously the wrong approach :P
#
# editor = emacs -nw -f text-mode
# editor = emacs -nw --eval '(setq nc:use-flyspell nil)' -f flyspell-mode
[pager]
# Always use pager when showing status.
status = true
# Use the 'diff-highlight' contrib script to highlight word changes
# in diffs. See /usr/share/doc/git/contrib/diff-highlight/README for
# more info and options. Also described in the Git 2.9 release
# summary:
# https://blog.github.com/2016-06-13-git-2-9-has-been-released/.
#
# The weird 'less -Mi -+F' is a duplication of my 'core.pager'
# setting.
log = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -Mi -+F
diff = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -Mi -+F
show = perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight | less -Mi -+F
[color]
ui = auto
[log]
# Show times in my time zone.
#
# This triggers a bug in `git stash list`: the stashes receive
# relative dates instead of numbers (e.g. 'starch@{0}' for the
# first stash). The bug is fixed here (gmane git list: git stash
# list shows timestamp in stead of "stash number", when setting
# date = local for log in config, 2009 September 15):
#
# http://thread.gmane.org/gmane.comp.version-control.git/128569
#
# and then later reintroduced, which is discussed here (magit
# list: Bug in git-stash(.sh) ?, 2012 April 27):
#
# https://groups.google.com/forum/?fromgroups#!topic/magit/KpJtJ956D3Y
#
# So, looks like it's been fixed recently, but is not in stable
# gits on ubuntu :P
#date = local
date = relative
[grep]
extendedRegexp = true
[merge]
# Fancier setup at http://emacswiki.org/emacs/EmergeDiff
tool = emerge
# Make 'git fetch; git merge' behave like 'git pull' on the
# current branch.
defaultToUpstream = true
# Show common ancestor version, in addition to "mine" and "theirs"
# hunks when marking up merge conflicts.
#
# E.g., if I have a README with contents "Version 1", and then I
# change it to "Version 2" in master and to "Version branch" in a
# branch, then merge the branch into master, by default I get
#
# $ git merge branch
# $ cat README
# <<<<<<< HEAD
# Version 2
# =======
# Version in branch
# >>>>>>> branch
#
# on the other hand, using the 'diff3' conflictstyle, I get
#
# $ git -c merge.conflictstyle=diff3 merge branch
# $ cat README
# <<<<<<< HEAD
# Version 2
# ||||||| merged common ancestors
# Version 1
# =======
# Version in branch
# >>>>>>> branch
#
# which additionally shows the common ancestor version. It's a
# little more to delete when resolving conflicts, but also
# additional helpful context.
conflictstyle = diff3
[pull]
# Don't allow non-fastforward merges on pull.
ff = only
[push]
# Make `git push` only push the current branch, and only if it has
# matching name upstream branch.
default = simple
[diff]
# Helpful if you don't know which file is which.
#mnemonicprefix = true
# Helpful if you want to double click copy a file name.
noprefix = true
[blame]
date = relative
# Doesn't matter if these files exist or not. Overridden values that
# already appear above are configured twice, but only the last value
# matters for single-value config parameters like 'user.name' and
# 'user.email'.
[include]
path = ~/.gitconfig.system-custom
# Automatically added when I used Git LFS on Brittle.
[status]
showUntrackedFiles = all
# For the `git absorb` extension
[absorb]
# Don't create multiple fixup commits with the same target commit
oneFixupPerCommit = true
[credential]
helper = cache --timeout=86400
# Auto translate https github urls to ssh.
[url "git@github.com:"]
insteadOf = https://github.com/
# Use SSH to sign commits.
[gpg]
format = ssh
# Sign commits to by default.
[commit]
gpgsign = true
# Use first key returned by agent to sign commits.
[gpg "ssh"]
defaultKeyCommand = ssh-add -L
# Git !-aliases are run with current dir set to `git rev-parse
# --show-toplevel`, with the variable 'GIT_PREFIX' set to `git
# rev-parse --show-prefix`.
[alias]
# WARNING: the '!' alias run at the *top-level* of the repo.
# List all aliases.
aliases = config --get-regexp alias
# Amend, reusing the commit message.
autoamend = commit --amend -CHEAD
# Pull, stashing and popping local changes automatically.
pullstash = -c rebase.autoStash=true pull --rebase
# Work around 'log.date = local' bug discussed above.
stashlist = !git stash list --date=default
# Ignore changes in versioned files
#
# Ignore changes in argument FILES
ignore-changes-set = update-index --skip-worktree
# Unignore changes in argument FILES
ignore-changes-unset = update-index --no-skip-worktree
# List files with ignored changes set (no args)
ignore-changes-ls = !git ls-files -t | grep '^S ' | sed -re 's/^S //'
# Show diff for files with ignored changes set (no args)
ignore-changes-diff = !~/local/scripts/git/ignore-changes-diff.sh
# SVN style short aliases.
#
# from https://git.wiki.kernel.org/index.php/Aliases
st = status
ci = commit --verbose
br = branch
co = checkout
di = diff
# lgs -p
lgp = log --stat -p
lgs = log --stat
who = shortlog -sn
# On newer gits, --oneline abbreviates --pretty=oneline
# --abbrev-commit. To get more verbose commit info, append
# --pretty=short or similar
#
# grOneline = log --graph --all --pretty='format:%h %C(yellow)%ar%Creset %Cgreen%aN%Creset%C(yellow)%d%Creset %s'
# This version uses only one line per commit, and includes only
# the commit hash, the subject, and the refs. The refs are added
# with '--decorate', which does a much better job than '%d' used
# below: different colors for different kinds of refs (HEAD vs
# branches tags), and prefixes tags with 'tag: '.
grShort = log --graph --pretty=oneline --decorate --abbrev-commit
# The rest are based on http://stackoverflow.com/a/9074343/470844
gr2Lines = log --graph --format=format:'%C(red)%h%C(reset) %C(green)(%ad)%C(reset)%C(bold yellow)%d%C(reset) %C(yellow)%an%C(reset)%n''%C(white)%s%C(reset)' --abbrev-commit
# All entries have an extra newline here :P Using '%+b' to avoid
# two extra newlines when body is empty though.
grFull = log --graph --format=format:'%C(red)%h%C(reset) %C(green)(%ad)%C(reset)%C(bold yellow)%d%C(reset) %C(yellow)%an%C(reset)%n''%C(white)%s%C(reset)%n%+b' --abbrev-commit
# Seems like a bug: git will only accept lowercase versions of the
# above aliases.
grTopology = !git gr2lines --all --simplify-by-decoration
# Short alias for favorite graph command.
gr = !git gr2lines
######################################################################
# Clean up whitespace.
#
# See
# http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing/15398512#15398512
######################################################################
# Fix whitespace in HEAD commit.
fixws-head = !"git rebase --whitespace=fix HEAD~"
# Check that it's safe to fix whitespace.
#
# Called by whitespace fixers below.
fixws-is-safe = !"\
if [ -d \"$(git rev-parse --git-dir)/rebase-merge\" ] ; then \
echo \"Rebase in progress; can't 'git fixws'!\" ; \
false ; \
fi"
# Fix whitespace in the index while preserving a dirty tree, if
# any.
#
# Assuming your index is empty, some useful variations are:
#
# - fix whitespace in all changes in all versioned files:
#
# git add -u :/ && git fixws && git reset
#
# - fix whitespace in all unversioned files and in all changes in
# all versioned files:
#
# git add --all :/ && git fixws && git reset
#
# Logic:
#
# The 'git stash save' fails if the tree is clean (instead of
# creating an empty stash :P). So, we only 'stash' and 'pop' if
# the tree is dirty.
#
# The 'git rebase --whitespace=fix HEAD~' throws away the commit
# if it's empty, and adding '--keep-empty' prevents the whitespace
# from being fixed. So, we first check that the index is dirty.
#
# Also:
# - '(! git diff-index --quiet --cached HEAD)' is true (zero) if
# the index is dirty
# - '(! git diff-files --quiet .)' is true if the tree is dirty
#
# The 'rebase --whitespace=fix' trick is from here:
# http://stackoverflow.com/a/19156679/470844
fixws = !"\
git fixws-is-safe && \
if (! git diff-files --quiet .) && \
(! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git stash save FIXWS_SAVE_TREE && \
git rebase --whitespace=fix HEAD~ && \
git stash pop && \
git reset --soft HEAD~ ; \
elif (! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git rebase --whitespace=fix HEAD~ && \
git reset --soft HEAD~ ; \
fi"
# Fix whitespace in the index and the tree.
#
# Precede with 'git add -N <files>' to also fix whitespace in
# unversioned files <files>.
#
# Logic:
#
# The different cases are:
# - dirty tree and dirty index
# - dirty tree and clean index
# - clean tree and dirty index
#
# We have to consider separate cases because the 'git rebase
# --whitespace=fix' is not compatible with empty commits (adding
# '--keep-empty' makes Git not fix the whitespace :P).
fixws-global-tree-and-index = !"\
git fixws-is-safe && \
if (! git diff-files --quiet .) && \
(! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git add -u :/ && \
git commit -m FIXWS_SAVE_TREE && \
git rebase --whitespace=fix HEAD~2 && \
git reset HEAD~ && \
git reset --soft HEAD~ ; \
elif (! git diff-files --quiet .) ; then \
git add -u :/ && \
git commit -m FIXWS_SAVE_TREE && \
git rebase --whitespace=fix HEAD~ && \
git reset HEAD~ ; \
elif (! git diff-index --quiet --cached HEAD) ; then \
git commit -m FIXWS_SAVE_INDEX && \
git rebase --whitespace=fix HEAD~ && \
git reset --soft HEAD~ ; \
fi"
# Fix whitespace in the index and the tree.
#
# BROKEN: Does not work because the 'git rebase --whitespace=fix'
# is not compatible with empty commits (adding '--keep-empty'
# makes Git not fix the whitespace :P).
#
# fixws-global-tree-and-index =!\
# git commit --allow-empty -m FIXWS_SAVE_INDEX && \
# git add -u :/ && \
# git commit --allow-empty -m FIXWS_SAVE_TREE && \
# git rebase --whitespace=fix --keep-empty HEAD~2 && \
# git reset HEAD~ && \
# git reset --soft HEAD~
# Fix whitespace in local-tree files (sub-tree rooted at current
# dir). Fail gracefully if the index is dirty.
#
# The if-statements:
# - if index is clean
# - if tree is dirty
fixws-local-tree =!"\
cd \"$GIT_PREFIX\" && \
if git diff-index --quiet --cached HEAD ; then \
if ! git diff-files --quiet . ; then \
export GIT_EDITOR=: && \
git -c apply.whitespace=fix add -ue . && \
git checkout . && \
git reset ; \
fi ; \
else \
echo 'Your index is dirty! Bailing ...' >&2 && exit 1 ; \
fi"
# Fix whitespace in indexed files. Fail gracefully if the tree is
# dirty.
#
# We 'cd' to the top-level so that commands are relative the whole
# tree.
#
# The if-statements:
# - if tree is clean
# - if index is dirty
fixws-index =!"\
cd `git rev-parse --show-toplevel` && \
if git diff-files --quiet . ; then \
if ! git diff-index --quiet --cached HEAD ; then \
export GIT_EDITOR=: && \
git reset && \
git -c apply.whitespace=fix add -ue . && \
git checkout . ; \
fi ; \
else \
echo 'Your tree is dirty! Bailing ...' >&2 && exit 1 ; \
fi"
# Fix whitespace in the index and the local tree (sub-tree rooted
# at current dir).
#
# The complicated sequencing in the first branch: hide the index
# while fixing the tree, and then hide the tree while fixing the
# index. The 'git stash' is necessary if there are any
# non-indexed changes (not just in the current sub-tree, hence the
# `git rev-parse --show-toplevel`), but fails to create a stash if
# there are no non-indexed changes.
#
# Can't use 'git stash --keep-index' to save the tree first and
# avoid the 'git commit', since 'git stash' still stashes the
# indexed changes in this case, and so fixing whitespace errors in
# the index causes a conflict on 'git stash pop'.
fixws-local-tree-and-index =!"\
cd \"$GIT_PREFIX\" && \
if (! git diff-files --quiet `git rev-parse --show-toplevel`) && \
(! git diff-index --quiet --cached HEAD) ; then \
git commit --allow-empty -m FIXWS_SAVE_INDEX && \
git fixws-local-tree && \
git stash save FIXWS_SAVE_TREE && \
git reset --soft 'HEAD^' && \
git fixws-index && \
git stash pop ; \
elif (! git diff-files --quiet .) ; then \
git fixws-local-tree ; \
elif (! git diff-index --quiet --cached HEAD) ; then \
git fixws-index ; \
fi"
# This simpler version does not work because 'git stash save'
# does not create a stash when the tree is clean. In that case,
# the final 'git stash pop' does not do the right thing!
#
# git commit --allow-empty -m FIXWS_SAVE_INDEX && \
# git fixws-tree && \
# git stash save FIXWS_SAVE_TREE && \
# git reset --soft 'HEAD^' && \
# git fixws-index && \
# git stash pop