Cargo: Add a custom Git merge tool for Cargo.locks and Cargo.tomls

Created on 20 Jul 2015  路  6Comments  路  Source: rust-lang/cargo

It's terribly annoying to have tons of Cargo.lock and Cargo.toml merge conflicts when rebasing pretty much any Rust PR on any large repo. It would be nice to have custom merge tools that automatically do the right thing here.

A-git A-tooling

Most helpful comment

From reading the documentation/PRs linked in this ticket, I get the following understanding (please correct at any stage if I am wrong):

  • Custom git merge drivers need to be registered in .git/config and .gitattributes.
  • Custom git merge drivers are automatically invoked as soon as the conflict occurs. Hence we could start implementing this as a totally separate binary without needing any support for it in cargo.
    If the custom merge driver is activated in a repository, cargo would practically never see a lock file with merge conflicts again, unless the driver fails to resolve the conflicts.
  • Once the tool is mature enough, it could be included in cargo as a subcommand and cargo could automatically register the merge driver when it initializes a project.

Thoughts?
If my understanding is correct, then I would start working on such a merge driver :)

All 6 comments

To add to this, NPM/Yarn have already implemented this feature officially.

cc #5831

I really like this feature, and enjoy it a lot in yarn.

So there are actually two different solutions here, and I think we should follow npm's lead and implement both:

  • Teach cargo (or the TOML parser(s) cargo uses) to consume TOML files with merge conflict marks and resolve them
  • Implement a custom merge driver that can resolve merge conflicts in TOML files

Here are some references:

From reading the documentation/PRs linked in this ticket, I get the following understanding (please correct at any stage if I am wrong):

  • Custom git merge drivers need to be registered in .git/config and .gitattributes.
  • Custom git merge drivers are automatically invoked as soon as the conflict occurs. Hence we could start implementing this as a totally separate binary without needing any support for it in cargo.
    If the custom merge driver is activated in a repository, cargo would practically never see a lock file with merge conflicts again, unless the driver fails to resolve the conflicts.
  • Once the tool is mature enough, it could be included in cargo as a subcommand and cargo could automatically register the merge driver when it initializes a project.

Thoughts?
If my understanding is correct, then I would start working on such a merge driver :)

Was this page helpful?
0 / 5 - 0 ratings