-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitconfig
81 lines (76 loc) · 2.56 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
[user]
email = [email protected]
name = Walter Bonetti
[core]
editor = emacs
whitespace = trailing-space,space-before-tab
[color]
ui = auto
[apply]
whitespace = fix
[alias]
# List all aliases.
aliases = config --get-regexp alias
# Amend, reusing the commit message.
autoamend = commit --amend -CHEAD
######################################################################
# Clean up whitespace.
#
# See
# http://stackoverflow.com/questions/591923/make-git-automatically-remove-trailing-whitespace-before-committing/15398512#15398512
######################################################################
# 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"
[merge]
tool = meld