How to get only the name of files whose change is greater than spaces?

I am trying to get the name of files that have more changes than spaces. (In other words, I do not want to list files with changes to only spaces.)

I tried "git diff --name-only -w", it does not work. It lists all modified files, including only spaces.

+5
source share
2 answers

To solve this problem, I wrote a script to do this. Hope this is helpful to others.

#!/usr/bin/env bash GIT_REPO_ROOT=`git rev-parse --show-toplevel` # cd ${GIT_REPO_ROOT} for f in `git diff --name-only`; do MY_DIFF=`git diff -w ${GIT_REPO_ROOT}/${f}` if [[ ! ${MY_DIFF} == "" ]]; then echo ${GIT_REPO_ROOT}/${f} fi done 

This script reduces the result from 88 files ('git diff --name-only') to 8 files.

+4
source

Add the ignore-blank-lines option. Try

 git diff --name-only -w --ignore-blank-lines 
+1
source

Source: https://habr.com/ru/post/1203442/


All Articles