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

Re: Wrong conflicts on file splits

From
Jon Smirl <jonsmirl@gmail.com>
Date
May 4, 2009, 15:30 UTC
Message-ID
<9e4733910905040830w1800d461udde3fa5b314e278f@mail.gmail.com>
In-Reply-To
<49FF01AA.9010301@drmicha.warpmail.net>

On Mon, May 4, 2009 at 10:54 AM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 55 quoted lines
> Jon Smirl venit, vidit, dixit 04.05.2009 15:52:
>> On Mon, May 4, 2009 at 9:49 AM, Michael J Gruber
>> <git@drmicha.warpmail.net> wrote:
>>> Jon Smirl venit, vidit, dixit 04.05.2009 15:42:
>>>> On Mon, May 4, 2009 at 9:27 AM, Michael J Gruber
>>>> <git@drmicha.warpmail.net> wrote:
>>>>> Jon Smirl venit, vidit, dixit 04.05.2009 14:53:
>>>>>> I keep running into this problem, is there anything I can do to make
>>>>>> it better? I'm using stgit but this is a problem in git itself.
>>>>>>
>>>>>> I have a patch that splits file A into two files, A and B.
>>>>>> Now I merge with another tree and bring in a one line fix to A.
>>>>>> The fix touches the pre-split file A in a section that is going to end up in B.
>>>>>> Next I re-apply the patch that splits A into A and B.
>>>>>>
>>>>>> This results in a large conflict in the post split file A.
>>>>>> And no patch being applied to file B which is where the fix belongs.
>>>>>>
>>>>>> Repeat this process with a multi-line fix and the whole automated
>>>>>> merge process breaks down and I have to carefully figure everything
>>>>>> out by hand.
>>>>>>
>>>>>> The merge process seems to be unaware of the newly created file B. No
>>>>>> patches or conflict ever end up in it.
>>>>>>
>>>>>
>>>>> Can you provide a test case or at least a list of commands which you are
>>>>> issuing? You complain about "merge", but you say you are "applying a
>>>>> patch". Are you merging that patch from another branch, or are you
>>>>> really applying it as a patch (git-apply/cherry-pick/rebase/what-not)?
>>>>
>>>> What git command does stgit use internally on push/pop?
>>>>
>>>> It's the stg push of a patch creating a split on top of a change to
>>>> the section that is going to end up in file B that causes the problem.
>>>
>>> I see. So it's really rebasing/applying here rather then merging. I
>>> don't think they have the necessary info in order to do content-based
>>> patching across file boundaries.
>>
>> Are there git commands that can do this properly? stgit is just a
>> bunch of Python executing git commands, they can change which commands
>> are getting called.
>
> OK, I checked the source, and in fact stgit uses git's merge strategies.
>
> I also checked a simple example (splitting `seq 1 20`) in two. It seems
> that git's rename detection does not detect that to be a rename/copy
> (split). As a consequence, the merge strategy performs only a file based
> merge between the versions of A. One would need to teach git about "a
> better split detection" in order to cope with such a situation.
>
> On the other hand, if you know the split, can't you redo that manually?
> I mean, checkout the new version (with the multi-line fixes), split it,
> git-add and git-commit to resolve.
I have 14 more patches layered on top of the split. Redoing the split
manually causes a cascade of conflicts. You get into this situation
when working on a large series that takes time to debug and get right.
 My current solution is to undo the fixes to the split files, apply
the split, and then manually make new patches to redo the fix. That
avoids the cascade problem triggered by changing the patch that
creates the split.

Does it really need to do rename detection? The fact that a new file is created is recorded in the diff, there's no need to go searching for it.

-- 
Jon Smirl
jonsmirl@gmail.com
Previous: Michael J Gruber
Message 7 of 7 in “Wrong conflicts on file splits”
  1. Jon SmirlMay 4, 2009
  2. Michael J GruberMay 4, 2009
  3. Jon SmirlMay 4, 2009
  4. Michael J GruberMay 4, 2009
  5. Jon SmirlMay 4, 2009
  6. Michael J GruberMay 4, 2009
  7. Jon SmirlMay 4, 2009

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.