I am trying to only get lines with changes using git diff. However, it is still counting blank lines in a code block with changes.
Here is my git diff command:
git diff --ignore-all-space --ignore-blank-lines --numstat HEAD
Example original code:
public void myCodeChange() {
String s = "original"
return s;
}
Example changed code:
public void myCodeChange() {
String s = "changes"
return s;
}
Here is what the diff looks like:
public void myCodeChange() {
- String s = "original"
+ String s = "changes"
+
return s;
}
I expect this to be 1 line added when running my git diff, however it is returning 2 lines added. Is there a way to make it not count that blank line?
Please have a look at the documentation of --ignore-blank-lines:
Ignore changes whose lines are all blank.
The text is pretty clear that the option causes changes to be ignored only when they consist only of changes in blank lines.
I do not know of a way to not count the added blank line in your example text