Reputation: 517
If we have this code below:
1: int a = 1;
2: int b = 2;
3: int c = 3;
4: int d = 4;
And we removed line 2 and 3, and change line 1 into int a = 0;
e.g.
1: int a = 0;
2: int d = 4;
git diff will show output like this:
1: - int a = 1;
2: - int b = 2;
3: - int c = 3;
4: + int a = 0;
5: int d = 4;
How can I make git-diff not display the line 2 and 3
above? It should only output like this:
1: - int a = 1;
2: + int a = 0;
3: int d = 4;
I am creating a script and it will be easier for me to parse the diff result if it will only show the modified line (lines that has been really updated e.g. changed some value within the line) not the deleted lines
Is this possible with git-diff? If not, are there any other option to solve this?
Upvotes: 2
Views: 96
Reputation: 265946
No, it's not possible since you cannot know if a pair of deletion and addition was actually a modification.
How do you know that int a = 1
was changed to int a = 0
and not that int b = 2
was changed to int a = 0
?
Let me change your patch slightly and ask you which lines you would keep:
-int a = 1;
-int b = 2;
-int c = 3;
+int b = 1;
int d = 4;
-int a = 1;
-int b = 2;
-int c = 3;
+long c = 3;
int d = 4;
-int a = 1;
-int b = 2;
-int c = 3;
+float e = 4.2;
int d = 4;
-int a = 1;
-int b = 2;
-int c = 3;
+string name = "marc";
int d = 4;
Upvotes: 1