git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: Merge conflict when lines next to each other are changed

From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
Date
Dec 3, 2021, 16:52 UTC
Message-ID
<006001d7e866$1bd374b0$537a5e10$@nexbridge.com>
In-Reply-To
<C1412C97-E67D-44F0-AC40-2FB723AFD017@yeplaa.net>
On December 3, 2021 11:30 AM, Loic Fouray wrote:
Show 32 quoted lines
> > 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.
Previous: Loic FourayNext: Jean-Noël Avila
Message 6 of 8 in “Merge conflict when lines next to each other are changed”
  1. Loic FourayDec 1, 2021
  2. rsbecker@nexbridge.comDec 1, 2021
  3. Loic FourayDec 1, 2021
  4. rsbecker@nexbridge.comDec 1, 2021
  5. Loic FourayDec 3, 2021
  6. rsbecker@nexbridge.comDec 3, 2021
  7. Jean-Noël AvilaDec 3, 2021
  8. Loic FourayDec 3, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.