0

I have a file which has conflicts.

REGION lifetime counter
    (*
    //for test purposes lifetimecounter goes to movement detection in set delayed outputs
    IF #O AND NOT #fp_lifetime
        AND #CCF.config.se_operating_counter_enable.value
        AND #CCF.status.s_active
    THEN
        #CCF.status.av_lifetime.value += 2;
    END_IF;
    #fp_lifetime := #O;
    *)
<<<<<<< HEAD
    "S-B"
=======
    "S-A"
>>>>>>> base/master
END_REGION

Delete: <<<<<<< HEAD, "S-B", ======= and >>>>>>> base/master

After editing this file in NOTEPAD, resolving the conflict, I execute the command: git diff <path\to\the\file> In most cases I get the right result:

$  git diff <path\to\the\file>
diff --cc <path\to\the\file>
index 286d51c,b189c82..0000000
--- a/<path\to\the\file>
+++ b/<path\to\the\file>

However, sometimes I also receive the following, and here the reason is unknown:

$  git diff <path\to\the\file>
diff --cc <path\to\the\file>
index 286d51c,b189c82..0000000
--- a/<path\to\the\file>
+++ b/<path\to\the\file>
@@@ -485,7 -485,7 +485,6 @@@ BEGI
            END_IF;
            #fp_lifetime := #O;
            *)
-           "S-B"
-       END_REGION
+           "S-A"
 -      END_REGION

Where do the different outputs come from if I always execute the same thing in the file?

Final state:

REGION lifetime counter
    (*
    //for test purposes lifetimecounter goes to movement detection in set delayed outputs
    IF #O AND NOT #fp_lifetime
        AND #CCF.config.se_operating_counter_enable.value
        AND #CCF.status.s_active
    THEN
        #CCF.status.av_lifetime.value += 2;
    END_IF;
    #fp_lifetime := #O;
    *)
    "S-A"
END_REGION
isherwood
  • 58,414
  • 16
  • 114
  • 157
raiserle
  • 677
  • 8
  • 31
  • 1
    @Brian61354270 that happens in cases when you have changes coming from different branches (depending on the indentation of `+`/`-`, you know how the current file looks when compared with each _parent_). – eftshift0 Mar 29 '23 at 15:10
  • can you post what it looks like in the _final_ state? At least the block between `REGION` and `END_REGION` (both lines included). Actually the same block from `HEAD` would also be welcome. – eftshift0 Mar 29 '23 at 15:11
  • Please see [ask], then revise your post title to ask a clear, specific question. – isherwood Mar 29 '23 at 15:14
  • Doesn't it depend where you are when you say `git diff`? Maybe you should add `HEAD` to your `git diff` command. – matt Mar 29 '23 at 15:20
  • If I read it correctly, `END_REGION` is probably not in the original position or there is a different character following it (even an EOL or EOF) from what it was on each branch. Now, about the _other_ lines, it looks correct. From `HEAD`, it looks like you deleted `S-B` and added `S-A`. From the other parent, it only marks the line about `END_REGION` as having changed. – eftshift0 Mar 29 '23 at 15:22
  • @eftshift0: If I really change something in the line with `END_REGION`, e.g. insert a space, the output looks different. `- END_REGION` `++ END_REGION` – raiserle Mar 29 '23 at 15:26
  • This is a _looooooong shot_ **but** still possible..... I think you changed _that_ line (`END_REGION`) on both branches **with the same change(!!!!!)** when compared with their common ancestor. Is that the case? – eftshift0 Mar 29 '23 at 15:36
  • _and_, if that is the case, I **think** this behavior is coming from a rather recent change to make the size of conflicts smaller by accepting lines that where changed the same way in the different parent branches when there is a conflict. – eftshift0 Mar 29 '23 at 15:39

1 Answers1

0

Where do the different outputs come from if I always execute the same thing in the file?

When git marks a file as conflicted you can inspect which versions that git has used as inputs with git ls-files -u, see this answer for more details.

With that information you can create some temporary tags like

git tag inspect-1 ad5e6cfb620eb3086a399bd8dd63f039fa120358
git tag inspect-2 73dab4ca75450b2aeb048a5e5632011d95064e58
git tag inspect-3 12c32798081dd59a51295275ce1119f5d1662422

And then launch gitk "--exclude=refs/notes/*" --all & and press F2 to search for each tag. You then will be able to see where each contributing version is comming from.


The exclude notes ting is to ignore the cached test results from git-test, because you always use it to test and verify all your commits on a branch, right? Right? If not you really, really, really, really should!

hlovdal
  • 26,565
  • 10
  • 94
  • 165