I have a merge tool which unfortunately removes newlines at the end of the files. So after I've used this tool, I need to check if any of the files in the Git index have their trailing newlines removed.
git diff --cached
displays these trailing newline removals, but it also prints the full diff. I'd like to get a more concise view which only lists the file names of the changed files in the Git index which are lacking the trailing newline.
I tried to combine git diff --name-only
and git grep
, but I can't find the a regular expression to detect files without newline at the end of file. Expressions including \Z
don't seem to be recognized by git grep
even with extended regular expressions (-E
).