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

x/tools: implement three-way merge and use in all tools that apply fixes #68765

Open
adonovan opened this issue Aug 7, 2024 · 0 comments
Open
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented Aug 7, 2024

When analysis and refactoring tools suggest multiple fixes to the same file, those fixes should be treated as independent changes, each analogous to a separate CL. Just as multiple CLs are resolved into a linear sequence using a tool such as diff3 or git-mergetool, our fixes should be reconciled intelligently too. For example, two fixes that add the same import should compose to a single diff that adds the desired import only once.

Merging two changes may fail; in that case, the (arbitrary) winner should be applied, and the loser skipped and reported to the caller.

The task of this issue is to design and implement a three-way merge algorithm and use it from all our tools (multichecker, analysistest, gopls, etc) that produce multiple independent edits. A poor-quality implementation (e.g. fail on any conflict) may serve as a temporary placeholder for a more sophisticated one (e.g. fork+exec diff3 or git-mergetool, or implement the diff3 algorithm atop x/tools/internal/diff/lcs).

For more background, see:

@pjweinb @findleyr @timothy-king

@adonovan adonovan added Refactoring Issues related to refactoring tools Analysis Issues related to static analysis (vet, x/tools/go/analysis) labels Aug 7, 2024
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Aug 7, 2024
@gopherbot gopherbot added this to the Unreleased milestone Aug 7, 2024
@dr2chase dr2chase added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Refactoring Issues related to refactoring tools Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants