git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Merge conflict when lines next to each other are changed
@ 2021-12-01  9:30 Loic Fouray
  2021-12-01 12:18 ` rsbecker
  2021-12-03  7:13 ` Jean-Noël Avila
  0 siblings, 2 replies; 8+ messages in thread
From: Loic Fouray @ 2021-12-01  9:30 UTC (permalink / raw)
  To: git

Hi,

In a file, I have this 2 lines one below the other:

Repository: myvalue
Tag: 8.2.10

On my local branch i have updated repository myvalue.
On the upstream repo, they updated often the tag value (not updated of my side).

When i perform a merge from upstream to local branch, i have a conflit. 
It seems that it’s related to neighboring lines. 
Could you confirm that it ‘s a normal git operation?

Also, i need to automate this merge. Is It possible with git tools to avoid this conflict or to resolv this conflict automatically?

Thanks for tour help
Loïc 



^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Merge conflict when lines next to each other are changed
  2021-12-01  9:30 Merge conflict when lines next to each other are changed Loic Fouray
@ 2021-12-01 12:18 ` rsbecker
  2021-12-01 13:33   ` Loic Fouray
  2021-12-03 16:30   ` Loic Fouray
  2021-12-03  7:13 ` Jean-Noël Avila
  1 sibling, 2 replies; 8+ messages in thread
From: rsbecker @ 2021-12-01 12:18 UTC (permalink / raw)
  To: 'Loic Fouray', git

On December 1, 2021 4:30 AM, Loic Fouray wrote:
> In a file, I have this 2 lines one below the other:
> 
> Repository: myvalue
> Tag: 8.2.10
> 
> On my local branch i have updated repository myvalue.
> On the upstream repo, they updated often the tag value (not updated of my
> side).
> 
> When i perform a merge from upstream to local branch, i have a conflit.
> It seems that it’s related to neighboring lines.
> Could you confirm that it ‘s a normal git operation?
> 
> Also, i need to automate this merge. Is It possible with git tools to avoid this
> conflict or to resolve this conflict automatically?

I try to keep version-specific identifying information, which is already contained in git, out of my code. This includes change logs/history in each source file because git is good at keeping that information - it is redundant in the code. However, for organizations that need to do that, I suggest using clean/smudge filters so that the code inside the repository is clean, while things like the repo name and tag get injected into the code as git puts it into the working directory. The code is then cleaned up while being staged. This removes the possibility of the conflict on these lines by removing the differing lines. You can script this using a combination of sed and git commands. My own git front end does this all the time but it is not generally applicable to all platforms (only NonStop and MVS) so I have not contributed it.

Regards,
Randall


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Merge conflict when lines next to each other are changed
  2021-12-01 12:18 ` rsbecker
@ 2021-12-01 13:33   ` Loic Fouray
  2021-12-01 14:09     ` rsbecker
  2021-12-03 16:30   ` Loic Fouray
  1 sibling, 1 reply; 8+ messages in thread
From: Loic Fouray @ 2021-12-01 13:33 UTC (permalink / raw)
  To: rsbecker; +Cc: git

Thanks for your reply Randall. 
If i understand correctly, you use externals tools (sed ..) but there is no possibility to manage It directly by git (spécific options,merge strategy..) , that’s right?


Regards
Loïc

> Le 1 déc. 2021 à 13:19, rsbecker@nexbridge.com a écrit :
> 
> On December 1, 2021 4:30 AM, Loic Fouray wrote:
>> In a file, I have this 2 lines one below the other:
>> 
>> Repository: myvalue
>> Tag: 8.2.10
>> 
>> On my local branch i have updated repository myvalue.
>> On the upstream repo, they updated often the tag value (not updated of my
>> side).
>> 
>> When i perform a merge from upstream to local branch, i have a conflit.
>> It seems that it’s related to neighboring lines.
>> Could you confirm that it ‘s a normal git operation?
>> 
>> Also, i need to automate this merge. Is It possible with git tools to avoid this
>> conflict or to resolve this conflict automatically?
> 
> I try to keep version-specific identifying information, which is already contained in git, out of my code. This includes change logs/history in each source file because git is good at keeping that information - it is redundant in the code. However, for organizations that need to do that, I suggest using clean/smudge filters so that the code inside the repository is clean, while things like the repo name and tag get injected into the code as git puts it into the working directory. The code is then cleaned up while being staged. This removes the possibility of the conflict on these lines by removing the differing lines. You can script this using a combination of sed and git commands. My own git front end does this all the time but it is not generally applicable to all platforms (only NonStop and MVS) so I have not contributed it.
> 
> Regards,
> Randall
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Merge conflict when lines next to each other are changed
  2021-12-01 13:33   ` Loic Fouray
@ 2021-12-01 14:09     ` rsbecker
  0 siblings, 0 replies; 8+ messages in thread
From: rsbecker @ 2021-12-01 14:09 UTC (permalink / raw)
  To: 'Loic Fouray'; +Cc: git

On December 1, 2021 8:34 AM, Loic Fouray wrote:
> > Le 1 déc. 2021 à 13:19, rsbecker@nexbridge.com a écrit :
> >
> > On December 1, 2021 4:30 AM, Loic Fouray wrote:
> >> In a file, I have this 2 lines one below the other:
> >>
> >> Repository: myvalue
> >> Tag: 8.2.10
> >>
> >> On my local branch i have updated repository myvalue.
> >> On the upstream repo, they updated often the tag value (not updated
> >> of my side).
> >>
> >> When i perform a merge from upstream to local branch, i have a conflit.
> >> It seems that it’s related to neighboring lines.
> >> Could you confirm that it ‘s a normal git operation?
> >>
> >> Also, i need to automate this merge. Is It possible with git tools to
> >> avoid this conflict or to resolve this conflict automatically?
> >
> > I try to keep version-specific identifying information, which is already
> contained in git, out of my code. This includes change logs/history in each
> source file because git is good at keeping that information - it is redundant in
> the code. However, for organizations that need to do that, I suggest using
> clean/smudge filters so that the code inside the repository is clean, while
> things like the repo name and tag get injected into the code as git puts it into
> the working directory. The code is then cleaned up while being staged. This
> removes the possibility of the conflict on these lines by removing the
> differing lines. You can script this using a combination of sed and git
> commands. My own git front end does this all the time but it is not generally
> applicable to all platforms (only NonStop and MVS) so I have not contributed
> it.
> If i understand correctly, you use externals tools (sed ..) but there is no
> possibility to manage It directly by git (spécific options,merge strategy..) ,
> that’s right?

I avoid the merge problem by removing the lines that will cause conflicts from the source. You can use -Xtheirs to always choose the upstream, but I do not think that is going to give you the desired result in all cases. My suggestion is to avoid the problem. Yes, using an external tool for your clean/smudge filters is the suggestion if you must have the specific conflicting lines in your code.
-Randall




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Merge conflict when lines next to each other are changed
  2021-12-01  9:30 Merge conflict when lines next to each other are changed Loic Fouray
  2021-12-01 12:18 ` rsbecker
@ 2021-12-03  7:13 ` Jean-Noël Avila
  2021-12-03 13:31   ` Loic Fouray
  1 sibling, 1 reply; 8+ messages in thread
From: Jean-Noël Avila @ 2021-12-03  7:13 UTC (permalink / raw)
  To: Loic Fouray, git

Le 01/12/2021 à 10:30, Loic Fouray a écrit :
> Hi,
>
> In a file, I have this 2 lines one below the other:
>
> Repository: myvalue
> Tag: 8.2.10
>
> On my local branch i have updated repository myvalue.
> On the upstream repo, they updated often the tag value (not updated of my side).
>
> When i perform a merge from upstream to local branch, i have a conflit. 
> It seems that it’s related to neighboring lines. 
> Could you confirm that it ‘s a normal git operation?
>
> Also, i need to automate this merge. Is It possible with git tools to avoid this conflict or to resolv this conflict automatically?
>
> Thanks for tour help
> Loïc 
>
>
Hi,

This is a use-case for git attribute "merge" :

https://git-scm.com/docs/gitattributes#_performing_a_three_way_merge


BR


Jean-Noël


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Merge conflict when lines next to each other are changed
  2021-12-03  7:13 ` Jean-Noël Avila
@ 2021-12-03 13:31   ` Loic Fouray
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Fouray @ 2021-12-03 13:31 UTC (permalink / raw)
  To: Jean-Noël Avila; +Cc: git

Hi,

Thanks Jean-Noël for your reply.

When you create a custom merge driver on a specific file, do you know if It possible to apply it only on a part of the file and apply also the standard merge strategy on this file ? 
The purpose would be to able to identify other merge conflits if this is the case …
I don’t think that is possible..

Loïc 

Envoyé de mon iPhone

> Le 3 déc. 2021 à 08:13, Jean-Noël Avila <avila.jn@gmail.com> a écrit :
> 
> Le 01/12/2021 à 10:30, Loic Fouray a écrit :
>> Hi,
>> 
>> In a file, I have this 2 lines one below the other:
>> 
>> Repository: myvalue
>> Tag: 8.2.10
>> 
>> On my local branch i have updated repository myvalue.
>> On the upstream repo, they updated often the tag value (not updated of my side).
>> 
>> When i perform a merge from upstream to local branch, i have a conflit. 
>> It seems that it’s related to neighboring lines. 
>> Could you confirm that it ‘s a normal git operation?
>> 
>> Also, i need to automate this merge. Is It possible with git tools to avoid this conflict or to resolv this conflict automatically?
>> 
>> Thanks for tour help
>> Loïc 
>> 
>> 
> Hi,
> 
> This is a use-case for git attribute "merge" :
> 
> https://git-scm.com/docs/gitattributes#_performing_a_three_way_merge
> 
> 
> BR
> 
> 
> Jean-Noël
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Merge conflict when lines next to each other are changed
  2021-12-01 12:18 ` rsbecker
  2021-12-01 13:33   ` Loic Fouray
@ 2021-12-03 16:30   ` Loic Fouray
  2021-12-03 16:52     ` rsbecker
  1 sibling, 1 reply; 8+ messages in thread
From: Loic Fouray @ 2021-12-03 16:30 UTC (permalink / raw)
  To: rsbecker; +Cc: git

Hello Randall,

Regarding the clean/smudge filters usage, do you know if this filters could be triggered by the merge git? Indeed, it would good if the change performed by the filters could be integrated with the merge commit. 

Thanks
Loïc 

> Le 1 déc. 2021 à 13:19, rsbecker@nexbridge.com a écrit :
> 
> On December 1, 2021 4:30 AM, Loic Fouray wrote:
>> In a file, I have this 2 lines one below the other:
>> 
>> Repository: myvalue
>> Tag: 8.2.10
>> 
>> On my local branch i have updated repository myvalue.
>> On the upstream repo, they updated often the tag value (not updated of my
>> side).
>> 
>> When i perform a merge from upstream to local branch, i have a conflit.
>> It seems that it’s related to neighboring lines.
>> Could you confirm that it ‘s a normal git operation?
>> 
>> Also, i need to automate this merge. Is It possible with git tools to avoid this
>> conflict or to resolve this conflict automatically?
> 
> I try to keep version-specific identifying information, which is already contained in git, out of my code. This includes change logs/history in each source file because git is good at keeping that information - it is redundant in the code. However, for organizations that need to do that, I suggest using clean/smudge filters so that the code inside the repository is clean, while things like the repo name and tag get injected into the code as git puts it into the working directory. The code is then cleaned up while being staged. This removes the possibility of the conflict on these lines by removing the differing lines. You can script this using a combination of sed and git commands. My own git front end does this all the time but it is not generally applicable to all platforms (only NonStop and MVS) so I have not contributed it.
> 
> Regards,
> Randall
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Merge conflict when lines next to each other are changed
  2021-12-03 16:30   ` Loic Fouray
@ 2021-12-03 16:52     ` rsbecker
  0 siblings, 0 replies; 8+ messages in thread
From: rsbecker @ 2021-12-03 16:52 UTC (permalink / raw)
  To: 'Loic Fouray'; +Cc: git

On December 3, 2021 11:30 AM, Loic Fouray wrote:
> > Le 1 déc. 2021 à 13:19, rsbecker@nexbridge.com a écrit :
> >
> > On December 1, 2021 4:30 AM, Loic Fouray wrote:
> >> In a file, I have this 2 lines one below the other:
> >>
> >> Repository: myvalue
> >> Tag: 8.2.10
> >>
> >> On my local branch i have updated repository myvalue.
> >> On the upstream repo, they updated often the tag value (not updated
> >> of my side).
> >>
> >> When i perform a merge from upstream to local branch, i have a conflit.
> >> It seems that it’s related to neighboring lines.
> >> Could you confirm that it ‘s a normal git operation?
> >>
> >> Also, i need to automate this merge. Is It possible with git tools to
> >> avoid this conflict or to resolve this conflict automatically?
> >
> > I try to keep version-specific identifying information, which is already
> contained in git, out of my code. This includes change logs/history in each
> source file because git is good at keeping that information - it is redundant in
> the code. However, for organizations that need to do that, I suggest using
> clean/smudge filters so that the code inside the repository is clean, while
> things like the repo name and tag get injected into the code as git puts it into
> the working directory. The code is then cleaned up while being staged. This
> removes the possibility of the conflict on these lines by removing the
> differing lines. You can script this using a combination of sed and git
> commands. My own git front end does this all the time but it is not generally
> applicable to all platforms (only NonStop and MVS) so I have not contributed
> it.
> >

> Regarding the clean/smudge filters usage, do you know if this filters could be
> triggered by the merge git? Indeed, it would good if the change performed
> by the filters could be integrated with the merge commit.
>

I do not think my point came across. The idea is that the merge should not even see the lines that are causing the conflict because they are not in the file. Your file should have something like the following inside:

Repo: $repo$
Tag: $tag$

A smudge filter can replace the $repo$ with your repository name, and $tag$ with whatever appropriate tag is. A clean filter would remove the conflicting content so merge would never see it.

If you are going to change the same line in each version just to identify that the version changed, you are always going to get conflicts.

[DO NOT DO THE FOLLOWNG] It is like doing the following:

Commit abc1213:

   Line1: This is version 1.0.

Commit 3533adf:

   Line1: This is version 1.1.

This is not how git is intended to be used, in my view.

-Randall

P.S. Please put your responses at the end on this mailing list.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-03 16:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-01  9:30 Merge conflict when lines next to each other are changed Loic Fouray
2021-12-01 12:18 ` rsbecker
2021-12-01 13:33   ` Loic Fouray
2021-12-01 14:09     ` rsbecker
2021-12-03 16:30   ` Loic Fouray
2021-12-03 16:52     ` rsbecker
2021-12-03  7:13 ` Jean-Noël Avila
2021-12-03 13:31   ` Loic Fouray

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).