Question

I am trying to find all the lines of code within the current git diff that have been deleted (in the unstaged changes) using the ruby gem grit, i.e. I want to see all the unstaged changes involving deletions. This would be the equivalent of doing git diff -U0 | grep ^-[^-] in the shell.

So far I have only been able to figure out how to get the diffs between two commits, or get the names of the files that have been changed.

Was it helpful?

Solution

Try as follows:

diff = @repo.git.diff({:U0 => true}).split( "\n" ).grep( /^-[^-]/ ).join( "\n" )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top