aboutsummaryrefslogtreecommitdiffstats
path: root/git/git-cdiff
blob: bd4ae31abbb0a019c4d3e1522990562d3da565a4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/dash
if test -z "${GIT_CDIFF_CONTEXT}"; then
	git difftool -y -x "diff -c --color=always" "$@"
elif echo "${GIT_CDIFF_CONTEXT}" | grep -q '^-'; then
	git difftool -y -x "diff ${GIT_CDIFF_CONTEXT} --color=always" "$@"
else
	git difftool -y -x "diff -C${GIT_CDIFF_CONTEXT} --color=always" "$@"
fi | {
	if test "$TERM" = linux; then
		sed '/^\(\x1b\[[0-9;]*m\)* /s/\x1b\[[0-9;]*m//g'
	else
		sed '/^\(\x1b\[[0-9;]*m\)* /s/^/\x1b\[2m/g'
	fi
} | {
	if test -t 1; then
		less -R
	else
		cat
	fi
}