Expose git_repository_set_config function
#1208
Merged
+31
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On my local machine, I set
diff.noPrefixto true in my global Git configuration.This can interfere with software that uses git2. For instance, running
cargo testin this repository causes thediff::tests::format_email_simpletest to fail as it's expecting lines with the "a/" and "b/" prefixes:git2-rs/src/diff.rs
Lines 1694 to 1695 in 62e83e2
There's a couple of workarounds available:
I can prevent the global configuration from loading by using
git2::opts::set_search_pathand pointing it at a non-existent path. The downside is that it is itself a global option.I can (probably) use
git2::DiffOptionsto undo my local environment. This is a bit verbose but a great solution in many cases to ensure predictabilityI'm proposing exposing the
git_repository_set_configfunction to allow setting configuration for a particular repository instance. This gives the user full control of which configuration to load.