Take nonewline context into account in diff parser
What does this MR do?
The problem is that the parser doesn’t check which file doesn’t have no newline
, it only check that there's a nonewline
and add it for both sides of the diff.
My approach to fix this was to replace nonewline
with old-nonewline
and new-nonewline
based on context.
This takes into assumption that no diff will have \ No newline at end of file
before any changes.
The conflict parser also uses nonewline
. I’ll update it but I need to make sure that my approach to fix this problem is good.
Update:
As I've tested, the conflict parser will not be affected by the nonewline
problem.
These scenarios need to be tested / asserted:
-
a
doesn’t have new line butb
does. -
a
have new line butb
doesn’t. -
a
doesn’t have new line andb
doesn’t. -
a
have new line andb
does.
Are there points in the code the reviewer needs to double check?
Screenshots (if relevant)
Currently the diff looks like this for the different scenarios:
1- a
doesn’t have new line but b
does.
this branch | master 2d006b46 |
---|---|
diff:
$ git diff 3...4
diff --git a/d b/d
index 2e65efe..6178079 100644
--- a/d
+++ b/d
@@ -1 +1 @@
-a
\ No newline at end of file
+b
2- a
have new line but b
doesn’t.
this branch | master 2d006b46 |
---|---|
diff:
$ git diff master...t
diff --git a/a b/a
index 7898192..63d8dbd 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-a
+b
\ No newline at end of file
3- a
doesn’t have new line and b
doesn’t.
this branch | master 2d006b46 |
---|---|
diff:
$ git diff master...b
diff --git a/a b/a
index 2e65efe..63d8dbd 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-a
\ No newline at end of file
+b
\ No newline at end of file
4-a
have new line and b
does.
this branch | master 2d006b46 |
---|---|
diff:
$ git diff 1...2
diff --git a/test b/test
index 7187db3..304d8aa 100644
--- a/test
+++ b/test
@@ -1,2 +1,2 @@
-lorem
ipsum
+lorem
Does this MR meet the acceptance criteria?
-
Changelog entry added -
Documentation created/updated -
API support added - Tests
-
Added for this feature/bug -
All builds are passing
-
-
Conform by the merge request performance guides -
Conform by the style guides -
Branch has no merge conflicts with master
(if it does - rebase it please) -
Squashed related commits together
What are the relevant issue numbers?
Closes #28128 (closed)
Closes #22636 (closed)