4

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.

1 Answer 1

3

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)
Sign up to request clarification or add additional context in comments.

2 Comments

complicated! Why don't git make the math for us? What exactly does it mean in your image the number -74,0?
Note that in some cases when n2 or n4 are meant to be 0, they and their comma are omitted. I haven't figured out what those cases specifically are yet.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.