Compare revisions "straight mode" logic is backwards and undocumented
Summary
GitLab 15.5 included !80031 (merged), which added an option in Compare Revision to be the equivalent of git diff foo..bar
vs git diff foo...bar
, but there are two problems:
-
There is no documentation. In finding this , I went to https://docs.gitlab.com/ee/user/project/repository/branches/#compare to see what the new functionality was, but it's not captured at all in the docs (the compare operator menu, with ".." or "..." is neither mentioned in the text nor shown in the screenshots).
-
The logic, as implemented, is backwards of the git diff convention.
Steps to reproduce
Perform a diff of main
into production
in the example project below.
Example Project
See https://gitlab.com/aarongoldenthal/merge-test to illustrate the problem.
What is the current bug behavior?
Git implements git diff foo..bar
as equivalent to git diff foo bar
- it shows a comparison of the latest commits to branches foo and bar. In the example repo, this would be:
PS C:\merge-test> git diff production..main
diff --git a/config.json b/config.json
index 108000c..dab43c4 100644
--- a/config.json
+++ b/config.json
@@ -1,3 +1,4 @@
{
- "foo": "1.0.1"
+ "foo": "1.0.1",
+ "bar": "1.0.0"
}
Git implements git diff foo...bar
showing the differences from the latest common ancestor. In the example repo, this would be:
PS C:\merge-test> git diff production...main
diff --git a/config.json b/config.json
index 7b65054..dab43c4 100644
--- a/config.json
+++ b/config.json
@@ -1,3 +1,4 @@
{
- "foo": "1.0.0"
+ "foo": "1.0.1",
+ "bar": "1.0.0"
}
This is the opposite of what's being displayed in the GitLab, as shown below.
The compare default is the ".." menu option, but since they're backwards, the default option is now return different results in some cases. In many cases this would not be seen, but if common changes are made independently to both branches the results are different.
What is the expected correct behavior?
The GitLab display should match the git standard.
Relevant logs and/or screenshots
See above.
Output of checks
This bug happens on GitLab.com (and on-prem).