fix small bug when printing diff

This commit is contained in:
Fakerr 2017-03-04 18:37:30 +01:00
parent 2ce9d43916
commit e1620dd4ac

View file

@ -26,7 +26,7 @@ COMMITS=""
COMMITS_UNCOL=() # commits without colors
LESSKEY=false
SED_BIN="" # Sed option to use according OS.
VERSION="1.1.8"
VERSION="1.1.9"
# Are we in a git repo?
if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then
@ -182,7 +182,8 @@ function get_diff() {
DIFF_TIP=${ELT:0:7}
DIFF_CMD="git show $DIFF_TIP --color=always"
DIFF=$(eval ${DIFF_CMD} 2>/dev/null)
off=$(echo "$DIFF" | grep -c ".\{$CN\}") #Number of lines in the diff that are longer than terminal width.
tmp_diff="$(echo "$DIFF" | $SED_BIN "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g")" # remove colors escape codes
off=$(echo "$tmp_diff" | grep -c ".\{$CN\}") #Number of lines in the diff that are longer than terminal width.
DIFF_LINES_NUMBER="$(echo "$DIFF" | wc -l)"
DIFF_LINES_NUMBER=$(( DIFF_LINES_NUMBER + off ))
}