Understand output of range-diff

336 Views Asked by At

I rebased my feature branch over master and want to verify that I resolved all merge conflicts correctly.

I'm using git range-diff for that purpose:

git range-diff --dual-color  old-master..origin/my-branch new-master..my-branch

I've read the documentation trice, but still I'm having trouble understanding the output of range-diff. I'd appreciate if someone could help me with that.

I'm having trouble understanding diffs like this

 6:  1273567d876 !  6:  789a6775664 A-commit-message
    @@ Commit message
     
      ## some/path/something.php ##
     @@ some/path/something.php: function initTexts() {
    -             "text-a",
    -             "text-b",
    -             "text-c",
    +             "text-x",
    +             "text-y",
    +             "text-z",
     +            "text-added-in-the-commit-a",
     +            "text-added-in-the-commit-b",
              ] as $key) {
              

Note that

  1. the first three lines are dimmed and the - has a red background,
  2. the next three lines are bold and the - has a green background,
  3. and the last two lines are green, with no background

The way I read the documentation

  1. should indicate a line that was removed in the first commit range
  2. should indicate a line that was added in the second commit range
  3. should indicate a line that was added in both commit ranges

What I do not understand

  1. Why are there even - indicators, since no lines were actually deleted. Only new lines were added. The lines with - are also present in the second range.
  2. Why are "text-a",, "text-b",, "text-c",, "text-x",, "text-y", and "text-z", in the diff, but not for example "text-unrelated-22",.
  3. The selection of lines in the diff seems arbitrary to me.
  4. What should @@ Commit message tell me?

More information

First, git show shows me, that both commits indeed intended to do the same change.

git show 1273567d876
             "text-c",
+            "text-added-in-the-commit-a",
+            "text-added-in-the-commit-b",
         ] as $key) {

git show 789a6775664
             "text-z",
+            "text-added-in-the-commit-a",
+            "text-added-in-the-commit-b",
         ] as $key) {

If I check out the commits under question, we see that both had to apply the changes to different starting situation, which is expected:

git checkout 1273567d876 && (show content of some/path/something.php: function initTexts())10

            […]
            "text-unrelated-6",
            "text-a",
            "text-b",
            "text-c",
            "text-added-in-the-commit-a",
            "text-added-in-the-commit-b",
        ] as $key) {
git checkout 789a6775664 && (show content of some/path/something.php: function initTexts())

            […]
            "text-unrelated-6",
            "text-a",
            "text-b",
            "text-c",
            "text-unrelated-7",
            […]
            "text-unrelated-22",
            "text-x",
            "text-y",
            "text-z",
            "text-added-in-the-commit-a",
            "text-added-in-the-commit-b",
        ] as $key) {

Thanks in advance!

0

There are 0 best solutions below