Skip to content

Add straight mode for compare view

What does this MR do and why?

In !41286 (closed) there was the effort to make the "compare view" of repositories able to show "straight" changes. While working on this, I noticed that it was not only about the changes beeing invisible, but also about the commits beeing missing.

Let's take this git commit tree as example:

  A -> B -> C -> D
            \ -> E

Pre to this MR, the compare view showed something comparable to:

  • /compare/C...E shows: git rev-list C ^E -> nothing, as C does not contain any commits, which are not in E
  • /compare/E...C shows: git rev-list E ^C -> only commit E, because this one is not in C

After this, it will show:

  • /compare/C...E shows: git rev-list C ^E -> the one commit E, but all things missing as deletions
  • /compare/E...C shows: git rev-list E ^C -> the one commit E, but all things new as additions

An important matter: This MR does not change https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/git/commit.rb#L120 from: revisions = [head, "^#{base}"] # base..head to revisions = ["#{head}...#{base}"] if in straight mode. It might be good to do this, but this should be a story for another MR as it will have a huge effect on lots of tests and codebase.

Screenshots or screen recordings

I checked http://127.0.0.1:3000/gitlab-org/gitlab-test/-/network/v1.0.0?extended_sha1=gitaly-branches-test and found "v1.0.0" and "gitaly-branches-test" to have a similiar situation.

Bildschirmfoto_2022-02-06_um_23.48.36

I tested this with gdk with the following links (before the change):

Bildschirmfoto_2022-02-06_um_23.49.41

Bildschirmfoto_2022-02-06_um_23.49.36

and after the change:

Bildschirmfoto_2022-09-14_um_23.39.53

with straight=true

Bildschirmfoto_2022-09-14_um_23.42.31

and the other side

Bildschirmfoto_2022-09-14_um_23.40.09

and the other side with straight=true

Bildschirmfoto_2022-09-14_um_23.42.20

How to set up and validate locally

  1. Visit any group or project member pages such as http://127.0.0.1:3000/gitlab-org/gitlab-test/-/compare/v1.0.0...gitaly-branches-test
  2. Visit any group or project member pages such as http://127.0.0.1:3000/gitlab-org/gitlab-test/-/compare/gitaly-branches-test...v1.0.0

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by DracoBlue

Merge request reports

Loading