Re: Git is not recognizing some merge conflicts and just accepting incoming master version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hannes,

Thank you for having a look. Below my responses and further information:

On Fri, 15 Mar 2024 at 09:24, Johannes Sixt <j6t@xxxxxxxx> wrote:
>
> Am 14.03.24 um 11:30 schrieb Kai:
> > I am encountering strange behavior when trying to merge master into a
> > feature branch. Trying with guis VScode and Gitkraken, both are not
> > displaying all conflicts in the files correctly and are just accepting
> > some changes from master which are conflicts and break the code.
> >
> > I am including two example files as well as screenshots.
>
> No files were included in this message. Don't post screenshots when the
> content can also be represented as text.
>
> That said, a conflict needs three files, not two: the base version,
> their version, and our version. But better than file attachments would
> be to just paste the relevant parts into the message (if you know what
> the relevant parts are and that other parts are not relevant).

Ok, I was assuming that having the whole files may be better to
reproduce the problem, but if just the relevant parts are enough, let
me do that.

Here is an example from all three files:

### BASE FILE (I used git merge-base master hook-form to show the
ancestor commit)
export const AddListingForm = (active: number) => {


  const form = useForm({

    defaultValues: {
      city: { name: '', lat: 0, lon: 0 },
      neighborhood: { name: '', lat: 0, lon: 0, neighborhood: '' },



### MASTER BRANCH (THEIR VERSION):
export const AddListingForm = (active: number) => {
  const form = useForm({
    name: "add-listing-form",
    initialValues: {
      city: { name: "", lat: 0, lon: 0 },
      neighborhood: { name: "", lat: 0, lon: 0, neighborhood: "" },



### HOOK-FORM BRANCH (OUR VERSION):
export const AddListingForm = (active: number) => {


  const form = useForm({

    defaultValues: {
      city: { name: '', lat: 0, lon: 0 },
      neighborhood: { name: '', lat: 0, lon: 0, neighborhood: '' },


### GIT DIFF MASTER TO BASE FILE (git diff
12545fa846fb0d042a4ed29ee0699d89f1621bc2 master --
components/add-listing/forms/AddListingForm.ts)
   const form = useForm({
-
-    defaultValues: {
-      city: { name: '', lat: 0, lon: 0 },
-      neighborhood: { name: '', lat: 0, lon: 0, neighborhood: '' },
+    name: "add-listing-form",
+    initialValues: {

### GIT DIFF BASE FILE TO HOOK-FORM (git diff
12545fa846fb0d042a4ed29ee0699d89f1621bc2 hook-form --
components/add-listing/forms/AddListingForm.ts)
No diff in relevant part


So as you can see, in this case Master has changes to the base file at
the relevant part, while in the hook form branch we continued to use
the base file version of that part. Now maybe I misunderstand how
merge conflicts are supposed to work, but shouldn't I expect git
marking the changes master made as a conflict? Because in master parts
of the file were changed that I did not change in the new branch? When
I now merge, the code is not working, because masters code is applied
and it breaks other parts of the code in the same file.

If this is expected behavior, this is a big issue in this case, as I
cannot trust that after sorting all conflicts that my code will work.
In that case I would need to manually review every diff. Or is there
maybe a stricter mode for merge conflicts, to also highlight these
types of differences?

>
> > In the first example, the conflict of the UseFormReturn type changing
> > between the two versions of the file is not being recognized.
> >
> > In the second example the useForm hook is completely different between
> > master and the feature branch called hook-form, but no conflict is
> > displayed.
>
> These descriptions sound like the conflicts are of semantic kind. Git
> can't help in such cases. Git can only detect textual conflicts, that
> is, when both sides modify the same or adjacent lines of code in
> different ways.
>
> -- Hannes
>




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux