basarat
basarat

Reputation: 276181

git diff just the line numbers

Something like which likes were modified, added or removed

--- a/src/app/codemirror/codeEditor.tsx
+++ b/src/app/codemirror/codeEditor.tsx
M 12
+ 72
+ 73
- 83
- 84

The basic objective is to get nice status highlights like e.g. Atom (or VsCode):

enter image description here

I've gone through https://git-scm.com/docs/git-diff and can't figure it out.

Upvotes: 4

Views: 2139

Answers (1)

basarat
basarat

Reputation: 276181

The closest I have gotten is git diff -U0 i.e. Unified diff format with 0 spare lines. This generates output like:

enter image description here

Where each section @@ -n1,n2 +n3,n4 @@ means that previously (n1,n2) the lines n1 to n1+n2 are now lines n3 to n3+n4.

This means that

  • if n2 is zero then its all addition (Use n3 to n3 + n4 to highlight)
  • Else if n4 is zero then its all deletion (Use n3 to higlight)
  • Else its modification (Use n3 to highlight)

Upvotes: 3

Related Questions