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

Re: Trimming 'deadheads' (TREESAME 2nd parent) from revision walks?

From
Philip Oakley <philipoakley@iee.email>
Date
Sep 21, 2021, 13:36 UTC
Message-ID
<9b85811f-de5d-24b3-36f6-7e2f9be6cae0@iee.email>
In-Reply-To
<YUj0J+jY0jURkipM@coredump.intra.peff.net>

Hi Peff, On 20/09/2021 21:50, Jeff King wrote:

Show 45 quoted lines
> On Mon, Sep 20, 2021 at 12:40:21PM +0100, Philip Oakley wrote:
>
>> One thing that catches me, and I think others, is how the 'strategies'
>> work. IIUC a merge will look at each line in the diff, and accept any
>> change on either side that has no conflicts within the context zone.
>> It's only when there are changes from both sides that the selection
>> strategy kicks in. But it is difficult to describe, so it's easy to be
>> confused.
> I think you might be confusing the "ours" strategy (which takes the
> tree state of the first parent entirely) with the "ours" (and "theirs")
> options of the merge-recursive (or ort) strategy.
>
> You can see the difference with:
>
>   git init repo
>   cd repo
>   
>   echo base >file
>   git add file
>   git commit -m base
>   
>   echo main >file
>   git add file
>   git commit -m main
>   
>   git checkout -b side HEAD^
>   echo side >file
>   echo unrelated >another
>   git add file another
>   git commit -m side
>   
>   git checkout -b strategy-ours main
>   git merge -s ours side
>   
>   git checkout -b option-ours main
>   git merge -X ours side
>
> The strategy-ours merge will drop "another", because it was not in the
> first parent. Whereas option-ours will keep it, preferring the
> first parent only for the conflict in "file".
>
> You could construct a similar example where instead of a second file,
> there's enough content in "file" that some of it does not conflict.
>
> -Peff

Thanks for the clarification. I was probably over thinking the problem, by starting at the default and adding conditions that are extras to that, rather than  reducing the conditions!

The `theirs` strategy is really only suitable for maintainers, rather than solo coders, as it need to be 'old releases` that are kept, rather 'old cruft` (I've generated too much of that in my time).

Dscho's scripts (for anyone interested) for GfW are in https://github.com/git-for-windows/build-extra/blob/main/shears.sh#L16-L18 and  https://github.com/git-for-windows/build-extra/blob/main/ever-green.sh, though from the script perspective it's an 'ours' strategy.

Dscho has to locate the start commit via it's subject line, rather than it's topology.

-- Philip

Previous: Jeff KingNext: Philip Oakley
Message 6 of 9 in “Trimming 'deadheads' (TREESAME 2nd parent) from revision walks?”
  1. Philip OakleySep 18, 2021
  2. Jeff KingSep 19, 2021
  3. Ævar Arnfjörð BjarmasonSep 19, 2021
  4. Philip OakleySep 20, 2021
  5. Jeff KingSep 20, 2021
  6. Philip OakleySep 21, 2021
  7. Philip OakleySep 21, 2021
  8. Johannes SchindelinOct 5, 2021
  9. Philip OakleyOct 6, 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.