The mr diff command produces incorrect diff
Description
The glab mr diff <id> command produces diff with multiple identical hunks.
$ git clone git@gitlab.com:viktomas/test-project.git
$ cd test-project
$ glab mr diff 7
README.md
@@ -1 +1,3 @@
-# Initial readme
\ No newline at end of file
+# Initial readme
+
+and another line
-test.js
+test.ts
@@ -10,17 +10,17 @@
// This seems to be a result of only some next-line content triggering this issue and other content doesn't.
// If there is an empty line after, for example, this issue doesn't not occur
-function containingFunction(){
- function subFunction(){
+function containingFunction(): void{
+ function subFunctionA(): void{
console.log("Some Output");
}
// Issue is not present when the line after the function name and opening { is empty
- function subFunction(){
+ function subFunctionB(): void{
console.log("OPutput");
}
}
-function anotherFunction(){
+function anotherFunction(): void{
console.log("Other Output");
}
-test.js
+test.ts
@@ -10,17 +10,17 @@
// This seems to be a result of only some next-line content triggering this issue and other content doesn't.
// If there is an empty line after, for example, this issue doesn't not occur
-function containingFunction(){
- function subFunction(){
+function containingFunction(): void{
+ function subFunctionA(): void{
console.log("Some Output");
}
// Issue is not present when the line after the function name and opening { is empty
- function subFunction(){
+ function subFunctionB(): void{
console.log("OPutput");
}
}
-function anotherFunction(){
+function anotherFunction(): void{
console.log("Other Output");
}
-test.js
+test.ts
@@ -10,17 +10,17 @@
// This seems to be a result of only some next-line content triggering this issue and other content doesn't.
// If there is an empty line after, for example, this issue doesn't not occur
-function containingFunction(){
- function subFunction(){
+function containingFunction(): void{
+ function subFunctionA(): void{
console.log("Some Output");
}
// Issue is not present when the line after the function name and opening { is empty
- function subFunction(){
+ function subFunction(): void{
console.log("OPutput");
}
}
-function anotherFunction(){
+function anotherFunction(): void{
console.log("Other Output");
}
Expected Behavior vs Actual Behavior
The actual diff is:
curl "https://gitlab.com/viktomas/test-project/-/merge_requests/7.diff"
diff --git a/README.md b/README.md
index ae85919a0535749a8795ab09c860528da8010242..94eb8096221475d19657285d19b4c743ac86a090 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
-# Initial readme
\ No newline at end of file
+# Initial readme
+
+and another line
diff --git a/test.js b/test.ts
similarity index 85%
rename from test.js
rename to test.ts
index c1ea0991309626307fda037e76178532757ae46f..a6334f618a4f1d4de7835578888f31e8e9290842 100644
--- a/test.js
+++ b/test.ts
@@ -10,17 +10,17 @@
// This seems to be a result of only some next-line content triggering this issue and other content doesn't.
// If there is an empty line after, for example, this issue doesn't not occur
-function containingFunction(){
- function subFunction(){
+function containingFunction(): void{
+ function subFunctionA(): void{
console.log("Some Output");
}
// Issue is not present when the line after the function name and opening { is empty
- function subFunction(){
+ function subFunctionB(): void{
console.log("OPutput");
}
}
-function anotherFunction(){
+function anotherFunction(): void{
console.log("Other Output");
}
You see, there are only three hunks in the diff, but the glab mr diff 7 produces 3x same large hunk.
Possible Fix
I looked a little bit more at the issue you mentioned and it looks like the command is producing a diff consisting of all versions: https://gitlab.com/gitlab-org/cli/-/blob/main/commands/mr/diff/diff.go#L87. The API docs aren't really clear on this but perhaps this needs to just grab the first / most recent version? That seems to have the correct diff content from what I saw.
Found by @shaun35 in !997 (comment 972707911)
Logs
Your Environment
- Version used (Run
glab --version): built frommain(glab version 1.22.0-51-g298ac8a (2022-06-06)) - Operating System and version:
macOS monteray 12.4
Edited by Tomas Vik