Skip to content

Add the ability to set the filename's used for create_patch and merge #2

Open

Description

@bmwill

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:

  1. Adding the ability to set the names via an option in DiffOptions and MergeOptions
  2. Introduce a new thin wrapper File which is a tuple (filename, contents) which are passed into the create_patch and merge methods instead of just passing in their contents.

Activity

  1. sunshowers commented on Dec 23, 2020

    @sunshowers

    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.

  2. sunshowers commented on Dec 23, 2020

    @sunshowers

    Ah nvm:

    git -c "core.quotePath=false" diff --cached
    

    prints filenames without escaping them. Oh well.

  3. added a commit that references this issue on Jul 11, 2021
    aa3d7e3
  4. kpcyrd commented on Apr 15, 2024

    @kpcyrd

    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

  5. added a commit that references this issue on Sep 27, 2024
    53bcaae
  6. added a commit that references this issue on Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions