Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug merge-recursive.[ch] #1898

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

newren
Copy link

@newren newren commented Mar 30, 2025

As a wise man once told me, "Deleted code is debugged code!"

This series does some preparation, then moves the code shared between merge-recursive and merge-ort from the former to the latter, and then debugs the remainder of merge-recursive.[ch].

Series overview:

  • Patches 1-5: Preparation; switch remaining callers of merge-recursive.[ch] functions to merge-ort equivalents, and add sole remaining missing feature (diff-algorithm selection)
  • Patch 6: Nuke merge-recursive.[ch]
  • Patch 7-8: Cleanup testsuite; we don't need GIT_TEST_MERGE_ALGORITHM anymore

While the diffstat might look large, the non-test code changes are actually pretty small. The drivers of the big diffstat are:

  • We move a significant chunk of shared code from merge-recursive.[ch] to merge-ort.[ch], without modifying it
  • We delete (the remainder of) merge-recursive.[ch]
  • We rip out all the temporary GIT_TEST_MERGE_ALGORITHM stuff designed to let us reuse tests between recursive and ort

cc: Eric Sunshine [email protected]
cc: Elijah Newren [email protected]

newren added 8 commits March 29, 2025 19:18
Replace the use of merge_trees() from merge-recursive.[ch] with the
merge-ort equivalent.

Signed-off-by: Elijah Newren <[email protected]>
Switch from merge-recursive to merge-ort.  Adjust the following
testcases due to the switch:

* t6430: most of the test differences here were due to improved D/F
  conflict handling explained in more detail in ef52778 (merge
  tests: expect improved directory/file conflict handling in ort,
  2020-10-26).  These changes weren't made to this test back in that
  commit simply because I had been looking at `git merge` rather than
  `git merge-recursive`.  The final test in this testsuite, though, was
  expunged because it was looking for specific output, and the calls to
  output_commit_title() were discarded from merge_ort_internal() in its
  adaptation from merge_recursive_internal(); see 8119214
  (merge-ort: implement merge_incore_recursive(), 2020-12-16).

* t6436: This test is built entirely around rename/delete conflicts,
  which had a suboptimal handling under merge-recursive.  As explained
  in more detail in commits 1f3c9ba ("t6425: be more flexible with
  rename/delete conflict messages", 2020-08-10) and 727c75b ("t6404,
  t6423: expect improved rename/delete handling in ort backend",
  2020-10-26), rename/delete conflicts should each have two entries in
  the index rather than just one.  Adjust the expectations for all the
  tests in this testcase to see the two entries per rename/delete
  conflict.

* t6424: merge-recursive had a special check-if-toplevel-trees-match
  check that it ran at the beginning on both the merge-base and the
  other side being merged in.  In such a case, it exited early and
  printed an "Already up to date." message.  merge-ort got rid of
  this, and instead checks the merge base tree matching the other
  side throughout the tree instead of just at the toplevel, allowing
  it to avoid recursing into various subtrees.  As part of that, it
  got rid of the specialty toplevel message.  That message hasn't
  been missed for years from `git merge`, so I don't think it is
  necessary to keep it just for `git merge-recursive`, especially
  since the latter is rarely used.  (git itself only references it
  in the testsuite, whereas it used to power one of the three
  rebase backends that existed once upon a time.)

Signed-off-by: Elijah Newren <[email protected]>
The ort merge strategy has always used the histogram diff algorithm.
The recursive merge strategy, in contrast, defaults to the myers
diff algorithm, while allowing it to be changed.

Change the ort merge strategy to allow different diff algorithms, by
removing the hard coded value in merge_start() and instead just making
it a default in init_merge_options().  Technically, this also changes
the default diff algorithm for the recursive backend too, but we're
going to remove the final callers of the recursive backend in the next
two commits.

Signed-off-by: Elijah Newren <[email protected]>
The do_recursive_merge() function, which is somewhat misleadingly named
since its purpose in life is to do a *non*-recursive merge, had code to
allow either using the recursive or ort backends.  The default has been
ort for a very long time, let's just remove the code path for allowing
the recursive backend to be selected.

Signed-off-by: Elijah Newren <[email protected]>
More precisely, replace calls to merge_recursive() with
merge_ort_recursive().

Also change t7615 to quit calling out recursive; it is not needed
anymore, and we are in fact using ort now.

Signed-off-by: Elijah Newren <[email protected]>
As a wise man once told me, "Deleted code is debugged code!"  So, move
the functions that are shared between merge-recursive and merge-ort from
the former to the latter, and then debug the remainder of
merge-recursive.[ch].

Signed-off-by: Elijah Newren <[email protected]>
Both of these existed to allow use to reuse all the merge-related tests
in the testsuite while easily flipping between the 'recursive' and the
'ort' backends.  Now that we have removed merge-recursive and remapped
'recursive' to mean 'ort', we don't need this scaffolding anymore.

Signed-off-by: Elijah Newren <[email protected]>
This environment variable existed to allow the testsuite to reuse all
the merge-related tests in the testsuite while easily flipping between
the 'recursive' and the 'ort' backends.  Now that we have removed
merge-recursive and remapped 'recursive' to mean 'ort', we don't need
this scaffolding anymore.  Remove it from these three builtins.

Signed-off-by: Elijah Newren <[email protected]>
@newren newren force-pushed the endit-quote-debugging-unquote branch from 808991d to 3abcfe6 Compare March 30, 2025 06:41
@newren
Copy link
Author

newren commented Mar 31, 2025

/submit

Copy link

gitgitgadget bot commented Mar 31, 2025

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-1898/newren/endit-quote-debugging-unquote-v1

To fetch this version to local tag pr-1898/newren/endit-quote-debugging-unquote-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-1898/newren/endit-quote-debugging-unquote-v1

@@ -20,7 +20,6 @@ linux-breaking-changes)
linux-TEST-vars)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Eric Sunshine wrote (reply to this):

On Mon, Mar 31, 2025 at 11:55 AM Elijah Newren via GitGitGadget
<[email protected]> wrote:
> Both of these existed to allow use to reuse all the merge-related tests

s/use/us/

> in the testsuite while easily flipping between the 'recursive' and the
> 'ort' backends.  Now that we have removed merge-recursive and remapped
> 'recursive' to mean 'ort', we don't need this scaffolding anymore.
>
> Signed-off-by: Elijah Newren <[email protected]>

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the Git mailing list, Elijah Newren wrote (reply to this):

On Mon, Mar 31, 2025 at 10:34 AM Eric Sunshine <[email protected]> wrote:
>
> On Mon, Mar 31, 2025 at 11:55 AM Elijah Newren via GitGitGadget
> <[email protected]> wrote:
> > Both of these existed to allow use to reuse all the merge-related tests
>
> s/use/us/

Indeed, thanks!

> > in the testsuite while easily flipping between the 'recursive' and the
> > 'ort' backends.  Now that we have removed merge-recursive and remapped
> > 'recursive' to mean 'ort', we don't need this scaffolding anymore.
> >
> > Signed-off-by: Elijah Newren <[email protected]>

Copy link

gitgitgadget bot commented Mar 31, 2025

User Eric Sunshine <[email protected]> has been added to the cc: list.

Copy link

gitgitgadget bot commented Mar 31, 2025

User Elijah Newren <[email protected]> has been added to the cc: list.

Copy link

gitgitgadget bot commented Apr 1, 2025

This patch series was integrated into seen via git@937fe0a.

@gitgitgadget gitgitgadget bot added the seen label Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant