Skip to content

Conversation

wetneb
Copy link

@wetneb wetneb commented Aug 18, 2025

This follows Git's merge driver interface which makes this information available using the %P variable. It is useful for merge drivers to adapt their behaviour based on the type of file supplied.

The motivation for this is that Mergiraf uses this information to determine the format of the file and parse its revisions accordingly. When the file format is determined by the file extension only, there is no need for this extra information as the file names of the base, left and right revisions will still have this extension (such as base_main.rs, left_main.rs, right_main.rs). But for files where the format is recognized by matching the entire file name, this will not work: base_Makefile isn't recognized on its own. However, when -p src/Makefile is provided, the tool is able to pick the right parsers.

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added/updated tests to cover my changes. (This area of the code does not seem to have any tests as far as I can tell)

@wetneb wetneb requested a review from a team as a code owner August 18, 2025 20:20
Copy link

google-cla bot commented Aug 18, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This follows Git's merge driver interface which makes this information
available using the `%P` variable. It is useful for merge drivers to
adapt their behaviour based on the type of file supplied.
@OvidiusCicero
Copy link
Contributor

@jj-vcs/maintainers can someone please have a look?

I like it and the implementation seems quite reasonable to me

Copy link
Member

@bnjmnt4n bnjmnt4n left a comment

Choose a reason for hiding this comment

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

SGTM. I suspect we might want to rename the variable to $path instead for consistency withjj fix.

@@ -253,6 +253,7 @@ fn run_mergetool_external_single_file(
})
.try_collect()?;
variables.insert("marker_length", conflict_marker_len.to_string());
variables.insert("repo_path", repo_path.as_internal_file_string().to_string());
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you update/add test in test_resolve_command.rs to include $repo_path or $path?

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

Successfully merging this pull request may close these issues.

4 participants