use git diff or git format-patch only to get the modified line ranges after the patch

136 views Asked by At

I'd like to be able to call git diff [something] <commit0>..<commit1> and get the filenames and line numbers in commit 1 that had been modified since commit 0. Currently, if I have

# foo.txt
foo

bar

and change '\nbar\n' -> 'baz', I get

diff --git a/foo.txt b/foo.txt
index 29a4dcd7..28932e58 100644
--- a/foo.txt
+++ b/foo.txt
@@ -1,5 +1,4 @@
 # foo.txt
 foo
-
-bar
+baz

How do I instruct git diff to isolate that line 2 (1-indexed) of the new version of foo.txt was modified? Is it possible without jumping into scripting languages?

0

There are 0 answers