GNU bug report logs - #44379
File name affects patch patched file regardless of diff

Previous Next

Package: diffutils;

Reported by: Michael Partridge <mcp292 <at> nau.edu>

Date: Sun, 1 Nov 2020 22:36:02 UTC

Severity: normal

To reply to this bug, email your comments to 44379 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#44379; Package diffutils. (Sun, 01 Nov 2020 22:36:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Michael Partridge <mcp292 <at> nau.edu>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Sun, 01 Nov 2020 22:36:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Partridge <mcp292 <at> nau.edu>
To: bug-diffutils <at> gnu.org
Subject: File name affects patch patched file regardless of diff
Date: Sun, 1 Nov 2020 15:34:42 -0700
[Message part 1 (text/plain, inline)]
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.

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.


MCP
[Message part 2 (text/html, inline)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#44379; Package diffutils. (Mon, 02 Nov 2020 13:15:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Andreas Grünbacher <agruen <at> gnu.org>
To: Michael Partridge <mcp292 <at> nau.edu>
Cc: bug-diffutils <at> gnu.org, 44379 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#44379: File name affects patch patched file
 regardless of diff
Date: Mon, 2 Nov 2020 14:14:19 +0100
Am So., 1. Nov. 2020 um 23:36 Uhr schrieb Michael Partridge <mcp292 <at> nau.edu>:
> 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




Information forwarded to bug-diffutils <at> gnu.org:
bug#44379; Package diffutils. (Mon, 02 Nov 2020 13:15:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-diffutils <at> gnu.org:
bug#44379; Package diffutils. (Mon, 02 Nov 2020 16:48:02 GMT) Full text and rfc822 format available.

Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Partridge <mcp292 <at> nau.edu>
To: Andreas Grünbacher <agruen <at> gnu.org>
Cc: bug-diffutils <at> gnu.org, 44379 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#44379: File name affects patch patched file
 regardless of diff
Date: Mon, 2 Nov 2020 09:46:56 -0700
[Message part 1 (text/plain, inline)]
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 <agruen <at> gnu.org> wrote:

> Am So., 1. Nov. 2020 um 23:36 Uhr schrieb Michael Partridge <
> mcp292 <at> nau.edu>:
> > 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
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-diffutils <at> gnu.org:
bug#44379; Package diffutils. (Mon, 02 Nov 2020 16:48:02 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 57 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.