Subject: Re: [bug-diffutils] bug#44379: File name affects patch patched file regardless of diff

From: Michael Partridge <[email-masked]>
Date: Mon, 2 Nov 2020 09:46:56 -0700

Thank you for the answer. Yes I usually do use git commands like `git
checkout -p`, but sometimes I need finer grain control over what lines I'm
merging. I ended up finding my solution with the answer below, but I guess
I could do something similar with `git checkout -p` and using `e` to edit.
The nice thing about my findings below is it can be used outside of git.

https://stackoverflow.com/a/64635564/4682839

On Mon, Nov 2, 2020 at 6:14 AM Andreas Grünbacher <[email-masked]> wrote:

> Am So., 1. Nov. 2020 um 23:36 Uhr schrieb Michael Partridge <
> [email-masked]>:
> > Reproduce with:
> >
> > diff -u driver.c.master driver.c > d.diff
> > patch < d.diff
> >
> > driver.c is patched instead of the intended driver.c.master. If I change
> the name to master_driver.c it works as intended.
>
> Unfortunately, patch has no way of knowing what you mean. The filename
> selection algorithm is described here:
>
>
> https://www.gnu.org/software/diffutils/manual/html_node/Multiple-Patches.html
>
> > The use case:
> > When I want to merge a couple lines of changes from another git branch,
> I sometimes rename the file in the master branch by appending .master then
> checkout the file that has some of the changes I want. From there I run the
> diffs as seen above and manually edit the diff file to achieve the exact
> edits I want before patching.
>
> Since you're in a git workflow already, you may be better served by
> "git diff", "git add -p", "git reset", and similar commands.
> Alternatively, use diff's --label option.
>
> Andreas
>