-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdotbash_git
92 lines (84 loc) · 2.69 KB
/
dotbash_git
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
#!/bin/bash
#
# GIT Specific hacks
#
GIT_MSG=""
#
# GIT Stuff
#
export GIT_AUTHOR_NAME="Alex Bennée"
: ${GIT_AUTHOR_EMAIL:="[email protected]"}
export GIT_AUTHOR_EMAIL # over-ride with .bash_${host} for work
export GIT_COMMITTER_NAME="Alex Bennée"
# Until I retrain my brain
alias git-diff='git diff'
alias git-commit='git commit'
alias git-log='git log'
alias git-push='git push'
alias git-grep='git grep'
# PS function
function ps_git_f() {
local s=
local d=$(git rev-parse --git-dir 2>/dev/null ) b= r= a= c=
if [[ -n "${d}" ]] ; then
if [[ -d "${d}/../.dotest" ]] ; then
if [[ -f "${d}/../.dotest/rebase" ]] ; then
r="rebase"
elif [[ -f "${d}/../.dotest/applying" ]] ; then
r="am"
else
r="???"
fi
b=$(git symbolic-ref HEAD 2>/dev/null )
elif [[ -f "${d}/.dotest-merge/interactive" ]] ; then
r="rebase-i"
b=$(<${d}/.dotest-merge/head-name)
elif [[ -d "${d}/../.dotest-merge" ]] ; then
r="rebase-m"
b=$(<${d}/.dotest-merge/head-name)
elif [[ -f "${d}/MERGE_HEAD" ]] ; then
r="merge"
b=$(git symbolic-ref HEAD 2>/dev/null )
elif [[ -f "${d}/BISECT_LOG" ]] ; then
r="bisect"
b=$(git symbolic-ref HEAD 2>/dev/null )"???"
else
r=""
b=$(git symbolic-ref HEAD 2>/dev/null )
fi
b=${b#refs/heads/}
b=${b// }
[[ -n "${b}" ]] && c="$(git config "branch.${b}.remote" 2>/dev/null )"
[[ -n "${r}${b}${c}${a}" ]] && s="/${r:+${r}:}${b}${c:+@${c}}${a:+ ${a}}"
fi
echo -n "$s"
}
cache_colour_scm=${cache_colour_m_orng}
ps_scm="\[${cache_colour_scm}\]\$(ps_git_f)\[${cache_colour_end}\]"
update_ps1 "\W$ps_scm"
#
# Report git log for a given file across all branches in the system
# See: http://stackoverflow.com/questions/25135102/finding-an-old-patch-in-one-of-many-git-topic-branches
#
function git_branches_touching
{
local hashes="`git log --format=format:"%H" --branches ^origin/master -- ${1}`"
for h in ${hashes}; do
local branches=`git branch --contains $h`
git log --oneline --format=format:"%C(auto)%h (%Cgreen${branches## }%Creset, %cr) %s" $h^..$h
done
}
#
# Do we want completion?
#
GIT_SRC=$(find_directories "${HOME}/src/git.git")
if [[ -f "${GIT_SRC}/contrib/completion/git-completion.bash" ]]; then
GIT_MSG="git.git completions"
source ${GIT_SRC}/contrib/completion/git-completion.bash
fi
# lets not get fancy for now
#echo "\$BASH_SOURCE ${BASH_SOURCE[@]}"
alias .git=". ~/.bash_git"
if [[ ! -z $GIT_MSG ]]; then
echo "loading .bash_git (Using: $GIT_MSG)"
fi