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

Declare merge-ort ready for general usage #905

Closed
wants to merge 13 commits into from

Conversation

newren
Copy link

@newren newren commented Mar 15, 2021

This series depends on ort-perf-batch-10[1], and obsoletes the ort-remainder topic[2] (that hadn't been picked up yet, so hopefully this doesn't cause any confusion)

With this series, merge-ort is ready for general usage -- it passes all tests, passes dozens of tests that don't under merge-recursive, and merge-ort is is already significantly faster than merge-recursive when rename detection is involved. Users can select merge-ort by (a) passing -sort to either git merge or git rebase, or (b) by setting pull.twohead=ort [3], or (c) by setting GIT_TEST_MERGE_ALGORITHM=ort.

Changes since v2:

  • changed the last patch to default testing to ort so people don't have to wait until CI for failures (but still keep linux-gcc testing merge-recursive so it retains coverage), as suggested by Stolee

[1] https://lore.kernel.org/git/pull.853.git.1615674128.gitgitgadget@gmail.com/
[2] https://lore.kernel.org/git/pull.973.v2.git.git.1615271086.gitgitgadget@gmail.com/
[3] See commit 14c4586 ("merge,rebase,revert: select ort or recursive by config or environment", 2020-11-02)

cc: Derrick Stolee dstolee@microsoft.com
cc: Ævar Arnfjörð Bjarmason avarab@gmail.com
cc: Taylor Blau me@ttaylorr.com
cc: Jonathan Tan jonathantanmy@google.com
cc: Jeff King peff@peff.net
cc: Jonathan Nieder jrnieder@gmail.com
cc: Johannes Schindelin Johannes.Schindelin@gmx.de
cc: Junio C Hamano gitster@pobox.com
cc: Derrick Stolee stolee@gmail.com
cc: Elijah Newren newren@gmail.com

@newren
Copy link
Author

newren commented Mar 16, 2021

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

Submitted as pull.905.git.1615867503.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-905/gitgitgadget/ort-readiness-v1

To fetch this version to local tag pr-905/gitgitgadget/ort-readiness-v1:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-905/gitgitgadget/ort-readiness-v1

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

On the Git mailing list, Derrick Stolee wrote (reply to this):

On 3/16/2021 12:05 AM, Elijah Newren via GitGitGadget wrote:
> This tiny series depends on ort-perf-batch-10[1].
> 
> If the ort-remainder topic[2] is merged with this series, then the result is
> a version of merge-ort ready for general usage. Users can select it by (a)
> passing -sort to either git merge or git rebase, or (b) by setting
> pull.twohead=ort [3], or (c) by setting GIT_TEST_MERGE_ALGORITHM=ort.

Does the other topic add GIT_TEST_MERGE_ALGORITHM=ort to the CI builds?

Specifically, the Linux builds have a second run with some optional
GIT_TEST_* environment variables. This seems like a nice addition.
 Other than that extra request, this series was easy to review. LGTM.
-Stolee

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

User Derrick Stolee <stolee@gmail.com> has been added to the cc: list.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

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

On Tue, Mar 16, 2021 at 10:01 AM Derrick Stolee <stolee@gmail.com> wrote:
>
> On 3/16/2021 12:05 AM, Elijah Newren via GitGitGadget wrote:
> > This tiny series depends on ort-perf-batch-10[1].
> >
> > If the ort-remainder topic[2] is merged with this series, then the result is
> > a version of merge-ort ready for general usage. Users can select it by (a)
> > passing -sort to either git merge or git rebase, or (b) by setting
> > pull.twohead=ort [3], or (c) by setting GIT_TEST_MERGE_ALGORITHM=ort.
>
> Does the other topic add GIT_TEST_MERGE_ALGORITHM=ort to the CI builds?
>
> Specifically, the Linux builds have a second run with some optional
> GIT_TEST_* environment variables. This seems like a nice addition.
>  Other than that extra request, this series was easy to review. LGTM.

The other topic left tests in t6423 failing.  This topic leaves the
tests in t6409 and t6418 failing; it's only the merge of the two that
has all passing tests.

I guess since the ort-remainder topic still hasn't been picked up, I
could just combine it with this series (basing on ort-perf-batch-10).
Then I could either add a patch at the end of the series that runs
tests under GIT_TEST_MERGE_ALGORITHM=ort, or which changes the default
merge backend to ort.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

User Elijah Newren <newren@gmail.com> has been added to the cc: list.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 16, 2021

On the Git mailing list, Derrick Stolee wrote (reply to this):

On 3/16/2021 1:25 PM, Elijah Newren wrote:
> On Tue, Mar 16, 2021 at 10:01 AM Derrick Stolee <stolee@gmail.com> wrote:
>>
>> On 3/16/2021 12:05 AM, Elijah Newren via GitGitGadget wrote:
>>> This tiny series depends on ort-perf-batch-10[1].
>>>
>>> If the ort-remainder topic[2] is merged with this series, then the result is
>>> a version of merge-ort ready for general usage. Users can select it by (a)
>>> passing -sort to either git merge or git rebase, or (b) by setting
>>> pull.twohead=ort [3], or (c) by setting GIT_TEST_MERGE_ALGORITHM=ort.
>>
>> Does the other topic add GIT_TEST_MERGE_ALGORITHM=ort to the CI builds?
>>
>> Specifically, the Linux builds have a second run with some optional
>> GIT_TEST_* environment variables. This seems like a nice addition.
>>  Other than that extra request, this series was easy to review. LGTM.
> 
> The other topic left tests in t6423 failing.  This topic leaves the
> tests in t6409 and t6418 failing; it's only the merge of the two that
> has all passing tests.

Combining the series might be the right call, or say this one depends
on that one.
 
> I guess since the ort-remainder topic still hasn't been picked up, I
> could just combine it with this series (basing on ort-perf-batch-10).
> Then I could either add a patch at the end of the series that runs
> tests under GIT_TEST_MERGE_ALGORITHM=ort, or which changes the default
> merge backend to ort. 

Perhaps change the backend to "ort" only when "features.experimental"
is enabled, at least for one full release? I'll do my part to do some
testing with our repos in that time, too.

Thanks,
-Stolee

rename/rename conflict handling depends on the fact that if both sides
renamed the same path, that the one on the MERGE_SIDE1 will appear first
in the combined diff_queue_struct passed to process_renames().  Since we
add all pairs from MERGE_SIDE1 to combined first, and then all pairs
from MERGE_SIDE2, and then sort based on filename, this will only be
true if the sort used is stable.  This was found due to the fact that
Mac, unlike Linux, apparently has a system-defined qsort that is not
stable.

While we are at it, review the other callers of QSORT and add comments
about why they can remain as calls to QSORT instead of being modified
to call STABLE_QSORT.

Signed-off-by: Elijah Newren <newren@gmail.com>
renormalize_buffer() requires an index_state, which is something that
merge-ort does not operate with.  However, all the renormalization code
needs is an index with a .gitattributes file...plus a little bit of
setup.  Create such an index, along with the deallocation and
attr_direction handling.

A subsequent commit will add a function to finish the initialization
of this index.

Signed-off-by: Elijah Newren <newren@gmail.com>
ll_merge() needs an index when renormalization is requested.  Create one
specifically for just this purpose with just the one needed entry.  This
fixes t6418.4 and t6418.5 under GIT_TEST_MERGE_ALGORITHM=ort.

NOTE 1: Even if the user has a working copy or a real index (which is
not a given as merge-ort can be used in bare repositories), we
explicitly ignore any .gitattributes file from either of these
locations.  merge-ort can be used to merge two branches that are
unrelated to HEAD, so .gitattributes from the working copy and current
index should not be considered relevant.

NOTE 2: Since we are in the middle of merging, there is a risk that
.gitattributes itself is conflicted...leaving us with an ill-defined
situation about how to perform the rest of the merge.  It could be that
the .gitattributes file does not even exist on one of the sides of the
merge, or that it has been modified on both sides.  If it's been
modified on both sides, it's possible that it could itself be merged
cleanly, though it's also possible that it only merges cleanly if you
use the right version of the .gitattributes file to drive the merge.  It
gets kind of complicated.  The only test we ever had that attempted to
test behavior in this area was seemingly unaware of the undefined
behavior, but knew the test wouldn't work for lack of attribute handling
support, marked it as test_expect_failure from the beginning, but
managed to fail for several reasons unrelated to attribute handling.
See commit 6f6e7cf ("t6038: remove problematic test", 2020-08-03) for
details.  So there are probably various ways to improve what
initialize_attr_index() picks in the case of a conflicted .gitattributes
but for now I just implemented something simple -- look for whatever
.gitattributes file we can find in any of the higher order stages and
use it.

Signed-off-by: Elijah Newren <newren@gmail.com>
When we have a modify/delete conflict, but the only change to the
modification is e.g. change of line endings, then if renormalization is
requested then we should be able to recognize such a case as a
not-modified/delete and resolve the conflict automatically.

This fixes t6418.10 under GIT_TEST_MERGE_ALGORITHM=ort.

Signed-off-by: Elijah Newren <newren@gmail.com>
merge-recursive has some simple code to support subtree shifting; copy
it over to merge-ort.  This fixes t6409.12 under
GIT_TEST_MERGE_ALGORITHM=ort.

Signed-off-by: Elijah Newren <newren@gmail.com>
If there is a conflict during a merge for a SKIP_WORKTREE entry, we
expect that file to be written to the working copy and have the
SKIP_WORKTREE bit cleared in the index.  If the user had manually
created a file in the working tree despite SKIP_WORKTREE being set, we
do not want to clobber their changes to that file, but want to move it
out of the way.  Add tests that check for these behaviors.

Signed-off-by: Elijah Newren <newren@gmail.com>
When merge conflicts occur in paths removed by a sparse-checkout, we
need to unsparsify those paths (clear the SKIP_WORKTREE bit), and write
out the conflicted file to the working copy.  In the very unlikely case
that someone manually put a file into the working copy at the location
of the SKIP_WORKTREE file, we need to avoid overwriting whatever edits
they have made and move that file to a different location first.

Signed-off-by: Elijah Newren <newren@gmail.com>
merge-ort handles submodules (and directory/file conflicts in general)
differently than merge-recursive does; it basically puts all the special
handling for different filetypes into one place in the codebase instead
of needing special handling for different filetypes in many different
code paths.  This one code path in merge-ort could perhaps use some work
still (there are still test_expect_failure cases in the testsuite), but
it passes all the tests that merge-recursive does as well as 12
additional ones that merge-recursive fails.  Mark those 12 tests as
test_expect_success under merge-ort.

Signed-off-by: Elijah Newren <newren@gmail.com>
There are a variety of questions users might ask while resolving
conflicts:
  * What changes have been made since the previous (first) parent?
  * What changes are staged?
  * What is still unstaged? (or what is still conflicted?)
  * What changes did I make to resolve conflicts so far?
The first three of these have simple answers:
  * git diff HEAD
  * git diff --cached
  * git diff
There was no way to answer the final question previously.  Adding one
is trivial in merge-ort, since it works by creating a tree representing
what should be written to the working copy complete with conflict
markers.  Simply write that tree to .git/AUTO_MERGE, allowing users to
answer the fourth question with
  * git diff AUTO_MERGE

I avoided using a name like "MERGE_AUTO", because that would be
merge-specific (much like MERGE_HEAD, REBASE_HEAD, REVERT_HEAD,
CHERRY_PICK_HEAD) and I wanted a name that didn't change depending on
which type of operation the merge was part of.

Ensure that paths which clean out other temporary operation-specific
files (e.g. CHERRY_PICK_HEAD, MERGE_MSG, rebase-merge/ state directory)
also clean out this AUTO_MERGE file.

Signed-off-by: Elijah Newren <newren@gmail.com>
The plan is to just delete merge-recursive, but not until everyone is
comfortable with merge-ort as a replacement.  Given that I haven't
switched all callers of merge-recursive over yet (e.g. git-am still uses
merge-recursive), maybe there's some value documenting known bugs in the
algorithm in case we end up keeping it or someone wants to dig it up in
the future.

Signed-off-by: Elijah Newren <newren@gmail.com>
This reverts commit 5ced7c3, which was
put in place as a temporary measure to avoid optimizations unstably
erroring out on no destination having a majority of the necessary
renames for directories that had no new files and thus no need for
directory rename detection anyway.  Now that optimizations are in place
to prevent us from trying to compute directory rename count computations
for directories that do not need it, we can undo this temporary measure.

Signed-off-by: Elijah Newren <newren@gmail.com>
When we started on merge-ort, thousands of tests failed when run with
the GIT_TEST_MERGE_ALGORITHM=ort flag; with so many, it didn't make
sense to flip all their test expectations.  The ones in t6409, t6418,
and the submodule tests are being handled by an independent in-flight
topic ("Complete merge-ort implemenation...almost").  The ones in
t6423 were left out of the other series because other ongoing series
that this commit depends upon were addressing those.  Now that we only
have one remaining test failure in t6423, let's mark it as such.

This remaining test will be fixed by a future optimization series, but
since merge-recursive doesn't pass this test either, passing it is not
necessary for declaring merge-ort ready for general use.

Signed-off-by: Elijah Newren <newren@gmail.com>
@newren
Copy link
Author

newren commented Mar 17, 2021

/submit

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 17, 2021

Submitted as pull.905.v2.git.1616016485.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git pr-905/gitgitgadget/ort-readiness-v2

To fetch this version to local tag pr-905/gitgitgadget/ort-readiness-v2:

git fetch --no-tags https://github.com/gitgitgadget/git tag pr-905/gitgitgadget/ort-readiness-v2

.github/workflows/main.yml Outdated Show resolved Hide resolved
@gitgitgadget
Copy link

gitgitgadget bot commented Mar 19, 2021

On the Git mailing list, Derrick Stolee wrote (reply to this):

On 3/17/2021 5:27 PM, Elijah Newren via GitGitGadget wrote:
> This series depends on ort-perf-batch-10[1], and obsoletes the ort-remainder
> topic[2] (that hadn't been picked up yet, so hopefully this doesn't cause
> any confusion)
> 
> With this series, merge-ort is ready for general usage -- it passes all
> tests, passes dozens of tests that don't under merge-recursive, and
> merge-ort is is already significantly faster than merge-recursive when
> rename detection is involved. Users can select merge-ort by (a) passing
> -sort to either git merge or git rebase, or (b) by setting pull.twohead=ort
> [3], or (c) by setting GIT_TEST_MERGE_ALGORITHM=ort.
> 
> Changes since v1:
> 
>  * subsumed the ort-remainder topic (the first 10 patches), which has
>    already been reviewed by both Ævar and Stolee[2].
>  * the next two patches were the original v1, reviewed by Stolee
>  * the final patch is new and adds testing.

Sorry for the delay in looking at this. I read the two series before
this, and found this to be a good union of them.

My only question on the final patch is a two parter:

1. Did you mean to go this far?
2. Did you want to go farther?

Mostly: how much do we want to prepare for ORT as the default
strategy, at the expense of reducing testing of the recursive
strategy?

Thanks,
-Stolee

In preparation for switching from merge-recursive to merge-ort as the
default strategy, have the testsuite default to running with merge-ort.
Keep coverage of the recursive backend by having the linux-gcc job run
with it.

Signed-off-by: Elijah Newren <newren@gmail.com>
@gitgitgadget
Copy link

gitgitgadget bot commented Mar 19, 2021

This branch is now known as en/ort-readiness.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 19, 2021

This patch series was integrated into seen via git@bab461d.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 29, 2021

This patch series was integrated into seen via git@dacf9fb.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 30, 2021

This patch series was integrated into seen via git@2c6478c.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 30, 2021

This patch series was integrated into seen via git@40cd16d.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 31, 2021

There was a status update about the branch en/ort-readiness on the Git mailing list:

Plug the ort merge backend throughout the rest of the system, and
start testing it as a replacement for the recursive backend.

@gitgitgadget
Copy link

gitgitgadget bot commented Mar 31, 2021

This patch series was integrated into seen via git@a7bd703.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 2, 2021

This patch series was integrated into seen via git@4cc959d.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 2, 2021

This patch series was integrated into seen via git@eb270b5.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 4, 2021

This patch series was integrated into seen via git@8246dda.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 6, 2021

This patch series was integrated into seen via git@6086de4.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 6, 2021

This patch series was integrated into seen via git@c0ed33e.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 6, 2021

This patch series was integrated into seen via git@3e5feb4.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 6, 2021

There was a status update about the branch en/ort-readiness on the Git mailing list:

Plug the ort merge backend throughout the rest of the system, and
start testing it as a replacement for the recursive backend.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 7, 2021

This patch series was integrated into seen via git@517283a.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 8, 2021

This patch series was integrated into seen via git@f917097.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 8, 2021

This patch series was integrated into seen via git@c25b67b.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 8, 2021

This patch series was integrated into seen via git@1f9af43.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 8, 2021

There was a status update about the branch en/ort-readiness on the Git mailing list:

Plug the ort merge backend throughout the rest of the system, and
start testing it as a replacement for the recursive backend.

Will merge to 'next'?

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 9, 2021

This patch series was integrated into seen via git@ed9ef8f.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 9, 2021

This patch series was integrated into next via git@20283a3.

@gitgitgadget gitgitgadget bot added the next label Apr 9, 2021
@gitgitgadget
Copy link

gitgitgadget bot commented Apr 13, 2021

There was a status update in the "Cooking" section about the branch en/ort-readiness on the Git mailing list:

Plug the ort merge backend throughout the rest of the system, and
start testing it as a replacement for the recursive backend.

Will merge to 'next'.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 14, 2021

This patch series was integrated into seen via git@e443742.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 15, 2021

This patch series was integrated into seen via git@13e74a9.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 16, 2021

There was a status update in the "Cooking" section about the branch en/ort-readiness on the Git mailing list:

Plug the ort merge backend throughout the rest of the system, and
start testing it as a replacement for the recursive backend.

Will merge to 'master'.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 16, 2021

This patch series was integrated into seen via git@7bec8e7.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 16, 2021

This patch series was integrated into next via git@7bec8e7.

@gitgitgadget
Copy link

gitgitgadget bot commented Apr 16, 2021

This patch series was integrated into master via git@7bec8e7.

@gitgitgadget gitgitgadget bot added the master label Apr 16, 2021
@gitgitgadget gitgitgadget bot closed this Apr 16, 2021
@gitgitgadget
Copy link

gitgitgadget bot commented Apr 16, 2021

Closed via 7bec8e7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant