{"thread":{"id":"58401","subject":"Patches produced with format-patch under specific config aren't applicable","startedAt":"2022-09-06T14:10:51Z","lastAt":"2022-09-07T02:19:20Z","messageCount":2,"participants":["Felipe Oliveira Carvalho","Đoàn Trần Công Danh"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"462653","messageId":"CAOC8YXak_QfPgxc=JWvzpaPGe9ZnFhDnR-36PrMG16qXFkQmsw@mail.gmail.com","threadId":"58401","inReplyTo":null,"subject":"Patches produced with format-patch under specific config aren't applicable","fromName":"Felipe Oliveira Carvalho","fromEmail":"felipekde@gmail.com","sentAt":"2022-09-06T13:45:41Z","receivedAt":"2022-09-06T14:10:51Z","isPatch":false,"sender":{"key":"felipekde@gmail.com","avatar":"https://gravatar.com/avatar/d3b0d3f3e680016d92159d539a9fcae3057490722dac4e206176bd4cf7e20e1b?d=mp&s=160"},"body":"Patches produced with format-patch under specific config aren't applicable\n\nInbox\nI have diff.noprefix=true on my ~/.gitconfig\n\n    [diff]\n        noprefix = true\n\nI generate a .patch file from the last commit with\n\n    git format-patch HEAD^\n\nDue to noprefix=true, I get this line in the patch file\n\n    diff --git src/filesystem/PhutilProcessQuery.php\nsrc/filesystem/PhutilProcessQuery.php\n\ninstead of the default\n\n    diff --git a/src/filesystem/PhutilProcessQuery.php\nb/src/filesystem/PhutilProcessQuery.php\n\nSo when I try to apply that patch, I get\n\n    $ git apply --check ./0001-my.patch\n    error: filesystem/PhutilProcessQuery.php: No such file or directory\n\nIn trying to remove the a/ and b/ that apply expects, it removes src/\nfrom the path, then fails to find filesystem/PhutilProcessQuery.php.\n\nAs a mitigation, I'm setting diff.noprefix to false, but a more robust\nsolution would be for the format-patch command to ignore this setting\nas patches are expected to work on repos configured by different\npeople.\n\ngit version 2.37.3\n--\nFelipe\n"},{"id":"462681","messageId":"Yxf/opwDZb/dLp29@danh.dev","threadId":"58401","inReplyTo":"CAOC8YXak_QfPgxc=JWvzpaPGe9ZnFhDnR-36PrMG16qXFkQmsw@mail.gmail.com","subject":"Re: Patches produced with format-patch under specific config aren't applicable","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2022-09-07T02:19:14Z","receivedAt":"2022-09-07T02:19:20Z","isPatch":false,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"On 2022-09-06 10:45:41-0300, Felipe Oliveira Carvalho <felipekde@gmail.com> wrote:\n> Patches produced with format-patch under specific config aren't applicable\n> \n> Inbox\n> I have diff.noprefix=true on my ~/.gitconfig\n> \n>     [diff]\n>         noprefix = true\n> \n> I generate a .patch file from the last commit with\n> \n>     git format-patch HEAD^\n> \n> Due to noprefix=true, I get this line in the patch file\n> \n>     diff --git src/filesystem/PhutilProcessQuery.php\n> src/filesystem/PhutilProcessQuery.php\n> \n> instead of the default\n> \n>     diff --git a/src/filesystem/PhutilProcessQuery.php\n> b/src/filesystem/PhutilProcessQuery.php\n> \n> So when I try to apply that patch, I get\n> \n>     $ git apply --check ./0001-my.patch\n>     error: filesystem/PhutilProcessQuery.php: No such file or directory\n> \n> In trying to remove the a/ and b/ that apply expects, it removes src/\n> from the path, then fails to find filesystem/PhutilProcessQuery.php.\n> \n> As a mitigation, I'm setting diff.noprefix to false, but a more robust\n> solution would be for the format-patch command to ignore this setting\n> as patches are expected to work on repos configured by different\n> people.\n\nYou can use \"-p0\" with git-am or git-apply to apply such patches.\n\nThere's a RFE in the past to add log.noprefix and/or format.noprefix\nbut it seems noone interested enough to work on it [1]\n\n1: https://lore.kernel.org/git/xmqqr1auvs7m.fsf@gitster.g/\n\n-- \nDanh\n"}]}