Add the ability to set the filename's used for `create_patch` and `merge`
Right now users are unable to set their own filenames, which appear when displaying a patch or when a merge has conflicts. There should be some interface which makes it easy for user's to overwrite the currently used defaults. A few options include:
- Adding the ability to set the names via an option in
DiffOptionsandMergeOptions - Introduce a new thin wrapper
Filewhich is a tuple (filename, contents) which are passed into thecreate_patchandmergemethods instead of just passing in their contents.
I was looking at implementing this because I'd like it in guppy, and I'm wondering whether we need to treat filenames slightly differently than we do not. I did some investigation and it looks like git diff escapes filenames that aren't UTF-8. On Linux (tested on zsh):
git init
touch foobar$'\224'
git add .
git diff --cached
prints
diff --git "a/foobar\224" "b/foobar\224"
new file mode 100644
index 0000000..e69de29
Think maybe we should do the same thing, unless there's another use case I might be missing.
Ah nvm:
git -c "core.quotePath=false" diff --cached
prints filenames without escaping them. Oh well.
I was wondering the same, Patch::new does pretty much what I need but isn't public.
For other people running into this issue, there's a crate that can be used in the meantime: https://crates.io/crates/diffy-fork-filenames