From 75cf44f8539730983be60394363e68168d5dc4ad Mon Sep 17 00:00:00 2001 From: Hari Sekhon Date: Thu, 10 Dec 2020 14:04:50 +0000 Subject: [PATCH] updated git.sh --- .bash.d/git.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.bash.d/git.sh b/.bash.d/git.sh index 5d35bc93..40a23a92 100644 --- a/.bash.d/git.sh +++ b/.bash.d/git.sh @@ -527,13 +527,12 @@ gitu(){ # go to the highest directory level to git diff inside the git repo boundary, otherwise git diff will return nothing basedir="$(basedir "$filename")" || return 1 pushd "$basedir" >/dev/null || return 1 - # XXX: this is returning the full name not the basename - changed_files="$(git status --porcelain "${filename##*/}" | + # XXX: needs -s to return the basename and not the full name + changed_files="$(git status --porcelain -s "${filename##*/}" | grep -e '^M' -e '^.M' | sed 's/^...//')" # while read line would auto-accepting the readline and commit without prompt :-/ - for changed_file in $changed_files; do - basename="${changed_file##*/}" + for basename in $changed_files; do diff="$(git diff --color=always -- "$basename"; git diff --cached --color=always -- "$basename")" if [ -z "$diff" ]; then continue