mirror of
https://github.com/Fakerr/git-recall.git
synced 2026-09-10 07:26:42 -04:00
remove empty lines
This commit is contained in:
parent
9b528b6413
commit
bf550a3d22
17
git-recall
17
git-recall
|
|
@ -28,7 +28,6 @@ LESSKEY=false
|
|||
SED_BIN="" # Sed option to use according OS.
|
||||
VERSION="1.1.11"
|
||||
|
||||
|
||||
# Set keys.
|
||||
au="`echo -e '\e[A'`" # arrow up
|
||||
ad="`echo -e '\e[B'`" # arrow down
|
||||
|
|
@ -45,7 +44,6 @@ if [[ ! -d ".git" ]] && ! git rev-parse --git-dir &>/dev/null; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Parse options
|
||||
while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
|
||||
case $1 in
|
||||
|
|
@ -76,7 +74,6 @@ while [[ "$1" =~ ^- && ! "$1" == "--" ]]; do
|
|||
done
|
||||
if [[ "$1" == "--" ]]; then shift; fi
|
||||
|
||||
|
||||
# Colored output.
|
||||
function colored() {
|
||||
GREEN=$(tput setaf 4)
|
||||
|
|
@ -93,7 +90,6 @@ function uncolored() {
|
|||
REVERSE=""
|
||||
}
|
||||
|
||||
|
||||
# Enable colors if supported by terminal.
|
||||
if [[ -t 1 ]] && [[ -n "$TERM" ]] && which tput &>/dev/null && tput colors &>/dev/null; then
|
||||
ncolors=$(tput colors)
|
||||
|
|
@ -106,13 +102,11 @@ else
|
|||
uncolored
|
||||
fi
|
||||
|
||||
|
||||
# Check if lesskey is installed.
|
||||
if command -v lesskey &> /dev/null; then
|
||||
LESSKEY=true
|
||||
fi
|
||||
|
||||
|
||||
# Set AUTHOR to current user if no param passed or display for all users if param equal to "all".
|
||||
if [[ ! -n $AUTHOR ]]; then
|
||||
AUTHOR=$(git config user.name 2>/dev/null)
|
||||
|
|
@ -120,7 +114,6 @@ elif [[ $AUTHOR = "all" ]]; then
|
|||
AUTHOR=".*"
|
||||
fi
|
||||
|
||||
|
||||
# Fetch changes before.
|
||||
if [[ $FETCH == true ]]; then
|
||||
echo "${GREEN}Fetching changes...${NORMAL}"
|
||||
|
|
@ -129,7 +122,6 @@ if [[ $FETCH == true ]]; then
|
|||
tput ed # clear screen
|
||||
fi
|
||||
|
||||
|
||||
# Log template.
|
||||
GIT_FORMAT="%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset"
|
||||
|
||||
|
|
@ -138,7 +130,6 @@ GIT_LOG="git log --pretty=format:'${GIT_FORMAT}'
|
|||
--author \"$AUTHOR\"
|
||||
--since \"$SINCE\" --abbrev-commit"
|
||||
|
||||
|
||||
# Change temporary the IFS to store GIT_LOG's output into an array.
|
||||
IFS=$'\n'
|
||||
COMMITS=($(eval ${GIT_LOG} 2>/dev/null))
|
||||
|
|
@ -150,7 +141,6 @@ CN=$(tput cols) # Screen's number of columns.
|
|||
TN=$(( $NI < $((SN -1)) ? $NI : $((SN -1)))) # Number of lines that we will display.
|
||||
OFFSET=0 #Incremented by one each time a commit's length is higher than teminal width.
|
||||
|
||||
|
||||
# If there is no items, exit.
|
||||
if [[ $NI = 0 ]]; then
|
||||
if [[ $AUTHOR = ".*" ]]; then
|
||||
|
|
@ -160,14 +150,12 @@ if [[ $NI = 0 ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Set correct sed option according OS's type
|
||||
case "$OSTYPE" in
|
||||
darwin*) SED_BIN="sed -E" ;;
|
||||
*) SED_BIN="sed -r" ;;
|
||||
esac
|
||||
|
||||
|
||||
# Create array with uncolred commits (removing escape sequences using sed)
|
||||
for elt in "${COMMITS[@]}"
|
||||
do
|
||||
|
|
@ -183,13 +171,11 @@ do
|
|||
fi
|
||||
done
|
||||
|
||||
|
||||
# Create a temporary lesskey file to change the keybindings so the user can use the TAB key to quit less. (more convenient)
|
||||
if [[ $LESSKEY = true ]]; then
|
||||
echo "\t quit" | lesskey -o $HOME/.lsh_less_keys_tmp -- - &> /dev/null
|
||||
fi
|
||||
|
||||
|
||||
## Get commit's diff.
|
||||
function get_diff() {
|
||||
ELT="$(echo "${COMMITS_UNCOL[$CP-1]}")"
|
||||
|
|
@ -202,7 +188,6 @@ function get_diff() {
|
|||
DIFF_LINES_NUMBER=$(( DIFF_LINES_NUMBER + off ))
|
||||
}
|
||||
|
||||
|
||||
## This function will print the diff according the commit's tip. If the diff is too long, the result will be displayed using 'less'.
|
||||
function print_diff() {
|
||||
get_diff # get commit's diff
|
||||
|
|
@ -242,7 +227,6 @@ function print_diff() {
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
# Calculate OFFSET to avoid bad redraw.
|
||||
function calculate_offset {
|
||||
tmp=1
|
||||
|
|
@ -259,7 +243,6 @@ function calculate_offset {
|
|||
done
|
||||
}
|
||||
|
||||
|
||||
{ # capture stdout to stderr
|
||||
|
||||
tput civis # hide cursor.
|
||||
|
|
|
|||
Loading…
Reference in a new issue