From unknown Fri Jun 20 07:28:06 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#44379 <44379@debbugs.gnu.org> To: bug#44379 <44379@debbugs.gnu.org> Subject: Status: File name affects patch patched file regardless of diff Reply-To: bug#44379 <44379@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:28:06 +0000 retitle 44379 File name affects patch patched file regardless of diff reassign 44379 diffutils submitter 44379 Michael Partridge severity 44379 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Sun Nov 01 17:35:03 2020 Received: (at submit) by debbugs.gnu.org; 1 Nov 2020 22:35:04 +0000 Received: from localhost ([127.0.0.1]:38889 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZLwF-0008RD-JY for submit@debbugs.gnu.org; Sun, 01 Nov 2020 17:35:03 -0500 Received: from lists.gnu.org ([209.51.188.17]:47114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZLwE-0008R5-DG for submit@debbugs.gnu.org; Sun, 01 Nov 2020 17:35:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZLwE-0004BQ-5n for bug-diffutils@gnu.org; Sun, 01 Nov 2020 17:35:02 -0500 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]:45463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZLwC-0008BW-3A for bug-diffutils@gnu.org; Sun, 01 Nov 2020 17:35:01 -0500 Received: by mail-ot1-x336.google.com with SMTP id f37so10887388otf.12 for ; Sun, 01 Nov 2020 14:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nau-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=uc4PyRNEbRUMBXMuzfwWQmIDNOL/nTwtwhIUy4DGkVI=; b=V7J5a2oCTiqLtZGNSTtlQvk58Yb7MWWNgq1ZD4fz7bH1z0vqQJEK6jk8AeaMD5AvzK PPkvnM6UNABIAegL+Z/+Jx7iecgcQ1LttER3qY261sLtiLWXvUImauelGY7MDQPvf4FN tCADYu7Qly2RDsYQDbyC5KPRq6YIDtSFkYNcZg2tZCsMFKrEFJQvwygMXWOw4dzrGTmr Wpr+HBwNVOhkCOcFQOkljnscY7J4BveBNhWcvKw4p/UIe2NpVVoIkPbzVz9TV7+AqQKb yNTlYa47iPmV3GVMqY5dV2YY2p+pR0ZQCVLSxz/fwiGQfyzdXRjYyuQL2QEGUdwpfNMU gNVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=uc4PyRNEbRUMBXMuzfwWQmIDNOL/nTwtwhIUy4DGkVI=; b=XwrlAesp7NZQVK9MVqqOEn9TTiipwVgJOyUZrs1U6VBKf3Q0MFDqmcbYZldjYVtUc8 iNck3efPtRAUliKopLXtx32zmfcFPzSpKNtpoxkMLEQKQ7mccO525My8F/uVB2sNi0Ni nxeXWBrz2ou6Z+0oKn4YucF7TbwOZuLoEuHojpZyD81gDw5fFoa4XouTEsFreLlNWn8+ XbDK/+cejhTaKXVPPmJOmHB8LK3nGp9sBGdF9nKQFpb3nDhdZga4YE7yBWNmPkZu/vYr RhSii94MOOdD9rUoZPB8mWb5xYcxgbGg638DdhHJdR0pyAJYfbhOclUdnwJz1hMFXnvm sq2g== X-Gm-Message-State: AOAM531TKOWrZ/VtGu9jtWpMPhcMjQy0QtpLAJgwRNVBgqp0nRmpGRG7 QaUC3cGB9o/cabxACGU90NGysYkRsptxz2Omlv6xhJsHARQ= X-Google-Smtp-Source: ABdhPJwVKNuMmMVE1Z/ek7WZVsGO8Kab4/yQgynVL4iR54CWRjkpY6tQKU/BWViRQ/tOGo4syYinZW2baqb/u6CclMA= X-Received: by 2002:a9d:1e82:: with SMTP id n2mr3948922otn.204.1604270098341; Sun, 01 Nov 2020 14:34:58 -0800 (PST) MIME-Version: 1.0 From: Michael Partridge Date: Sun, 1 Nov 2020 15:34:42 -0700 Message-ID: Subject: File name affects patch patched file regardless of diff To: bug-diffutils@gnu.org Content-Type: multipart/alternative; boundary="00000000000055f9c005b3133df9" Received-SPF: pass client-ip=2607:f8b0:4864:20::336; envelope-from=mcp292@nau.edu; helo=mail-ot1-x336.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --00000000000055f9c005b3133df9 Content-Type: text/plain; charset="UTF-8" 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 --00000000000055f9c005b3133df9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


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 renam= e 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

--00000000000055f9c005b3133df9-- From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 02 08:14:40 2020 Received: (at submit) by debbugs.gnu.org; 2 Nov 2020 13:14:40 +0000 Received: from localhost ([127.0.0.1]:40103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZZfT-0003Dw-Sf for submit@debbugs.gnu.org; Mon, 02 Nov 2020 08:14:40 -0500 Received: from lists.gnu.org ([209.51.188.17]:59114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZZfQ-0003Dm-Ay for submit@debbugs.gnu.org; Mon, 02 Nov 2020 08:14:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40390) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZZfQ-0001Pc-6W for bug-diffutils@gnu.org; Mon, 02 Nov 2020 08:14:36 -0500 Received: from mail-il1-f170.google.com ([209.85.166.170]:45534) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZZfM-00057u-IG for bug-diffutils@gnu.org; Mon, 02 Nov 2020 08:14:35 -0500 Received: by mail-il1-f170.google.com with SMTP id g7so12882738ilr.12 for ; Mon, 02 Nov 2020 05:14:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=s/E2gnfzt3zIwDCAuIcPLiV78qzi0B96gSY/N6IV3h8=; b=RGEBbAEf1wCdVC+8mEWu2HoOzfZ7uP34Fo6bmdM+tSlIpgYLdlm+XyL5mbD4jftpi+ MgO2W8hlUQb4xkg+xTqHAG6fdCEF2dVRq1ERbYpdpoMSwV7iQHE/pBfBOFyQm1K3xWDy zX1NcNEByWPf+rBz3jEZqEnGWW6GSvnt7iYji4yEPXN73SVE5aWl1eHZxrgD5ov8LMnQ L7JRzUsOFD9DBSbBKdKlBtH+R+dMwsSENBlVs9nC7J8bcMSQoVPHB23rQJ8VDg+pT9+F lMxFCfQEY9eRrpbmpMJoTwlb9//fSfz/zD067/G8d9SJtNu3nBNLM5rLvuRbIjeyN0el lFVw== X-Gm-Message-State: AOAM531Q3BwSz6wLOJnL1kaoKA45lf6lIUacYMrs0j5FYD3iozof5lj8 bHe5EeO9L6eXSvs/su11096s8mE+Ht2p4XeMk6o= X-Google-Smtp-Source: ABdhPJzEkg3Swxp38Qx9n7SW+8ow59ACYlw9AI3/CZFMZxDPU5pd9AmQynNKksjIYpJwT0Yny1MdugKxxLtirzZ8oK8= X-Received: by 2002:a92:98c5:: with SMTP id a66mr10892794ill.50.1604322871092; Mon, 02 Nov 2020 05:14:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Date: Mon, 2 Nov 2020 14:14:19 +0100 Message-ID: Subject: Re: [bug-diffutils] bug#44379: File name affects patch patched file regardless of diff To: Michael Partridge Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=209.85.166.170; envelope-from=andreas.gruenbacher@gmail.com; helo=mail-il1-f170.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 08:14:31 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -13 X-Spam_score: -1.4 X-Spam_bar: - X-Spam_report: (-1.4 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: -0.8 (/) X-Debbugs-Envelope-To: submit Cc: bug-diffutils@gnu.org, 44379@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.8 (-) Am So., 1. Nov. 2020 um 23:36 Uhr schrieb Michael Partridge : > 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.ht= ml > 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 c= heckout 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 ed= its 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 From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 02 11:47:19 2020 Received: (at submit) by debbugs.gnu.org; 2 Nov 2020 16:47:19 +0000 Received: from localhost ([127.0.0.1]:42399 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZczH-0000vR-6x for submit@debbugs.gnu.org; Mon, 02 Nov 2020 11:47:19 -0500 Received: from lists.gnu.org ([209.51.188.17]:50016) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZczE-0000vE-QO for submit@debbugs.gnu.org; Mon, 02 Nov 2020 11:47:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47710) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZczE-0001eT-J4 for bug-diffutils@gnu.org; Mon, 02 Nov 2020 11:47:16 -0500 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:46837) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZczC-0002wv-Bw for bug-diffutils@gnu.org; Mon, 02 Nov 2020 11:47:15 -0500 Received: by mail-oi1-x22d.google.com with SMTP id x1so15252102oic.13 for ; Mon, 02 Nov 2020 08:47:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nau-edu.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OEaqxRBun+jzZQWkBXOrkxYKqzW9VM1mMSSiSylRyQw=; b=UKlmv1ftQf31EithoduLcwR9TtToTAoqmOymkdx3FkQvu0quj0YA99xYntrejMazjd y7cZB/F1LuhMWkq+Mo8usx60gAongYt3I3tAwsKc89n06HxAzbPlKPsGA0JCI+WDCmiV mVGW6LNzAl4EMt1N2nkmjvqKft6fpWMaURN9Jt7vm6BMEbwbvlELNltPw8JI3wRbi1xm 3k3CQG6KqpfzTgPvi98/yAfr546vJegd2MBRBk7xxZCvcA0GLPLemLidY+Khjha3vU/q mB0spxPImrGVK7aLFcKl0N6+g5StXQG1YJFjpJwe1+RvmlxYgGCV2hwib7yghcQJ7G4G dG9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OEaqxRBun+jzZQWkBXOrkxYKqzW9VM1mMSSiSylRyQw=; b=E26e3nBOyJ+rgLei8/Z+Ta5sXkRrYQxniEl3hIJK8Df9C4WGbFOW6wIXzytGSwqEeS Rn6y16xlpyrWVpQnvwRPq14fumMWurD5/N9aaJqJs7IupZ9acYgXAFP/n/GIPg3G+nCT XVq0G9CDVAVKSZDo5DD9nYeu0mM4x0CVnULw7kB6rigN/n6D8KXfEkls4Ufn6brOD9TU vzr99+LRTzf3W1iq66I4JPneWXUrDQgH917g5ry4Wk8YN/NQUfH0J6LE7rOAZHgLQ92y 8GVP/CGP4mwEt4U5hn1OpyMIiASrHqq5RUZGZMbDLtzcJoETjFhX53josdNpN6ZVloVE nQ9Q== X-Gm-Message-State: AOAM530BhGlWjXiQklHQfwdwOkb3ldycVoqxU7SHU4yqx0WWbkL4+tVr Vmg7JnbzHj+sHxbKBkCUFLav9cbQ8gbvBweJqEWygLMX85SIJw== X-Google-Smtp-Source: ABdhPJx3/oPDG5u6HHJdyxrS2hC09A30SaSzEBdgxI0EFYkSLNy7KcNXiuggpEwragktAbkKp9lCqLVHpwxUhnbxhAo= X-Received: by 2002:aca:50d5:: with SMTP id e204mr10812100oib.32.1604335632698; Mon, 02 Nov 2020 08:47:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Michael Partridge Date: Mon, 2 Nov 2020 09:46:56 -0700 Message-ID: Subject: Re: [bug-diffutils] bug#44379: File name affects patch patched file regardless of diff To: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= Content-Type: multipart/alternative; boundary="0000000000007ce3be05b3227f40" Received-SPF: pass client-ip=2607:f8b0:4864:20::22d; envelope-from=mcp292@nau.edu; helo=mail-oi1-x22d.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit Cc: bug-diffutils@gnu.org, 44379@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --0000000000007ce3be05b3227f40 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=C3=BCnbacher wro= te: > Am So., 1. Nov. 2020 um 23:36 Uhr schrieb Michael Partridge < > mcp292@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 chang= e > 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 the= n > checkout the file that has some of the changes I want. From there I run t= he > 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 > --0000000000007ce3be05b3227f40 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thank you for the answer. Yes I usually do use git comm= ands 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.

<= /div>
O= n Mon, Nov 2, 2020 at 6:14 AM Andreas Gr=C3=BCnbacher <agruen@gnu.org> wrote:
Am So., 1. Nov. 2020 um 23:36 Uhr schrieb = Michael Partridge <m= cp292@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 chan= ge 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/sof= tware/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 the= n checkout the file that has some of the changes I want. From there I run t= he 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 si= milar commands.
Alternatively, use diff's --label option.

Andreas
--0000000000007ce3be05b3227f40--