Managing multiple patches for a source file
Seth McDonald
dev at sethm.id.au
Tue Sep 1 06:46:34 UTC 2026
Hi all,
Following the MacPorts guide on patching source code (see [0], section
4.6.2), it encourages using separate patchfiles for each logical change
and says to diff against the original file.
Given this, I'd like to ask what the about the situation in which
multiple logical changes need to be applied to the same source file.
Since each change may alter the line count of the file, I worry that
just diffing each change against the original file may cause later
patches to not apply due to the expected line numbers being changed.
I can think of three ways this can be managed:
(0) Keep all changes to the same source file within the same patchfile.
This way the problem never occurs, but removes the benefit of logically
separate patches.
(1) Diff each change against the original file. Perhaps I'm wrong and
MacPorts is actually smart enough to handle sequential patches which
each alter line numbers without the patchfiles accounting for it.
(2) Diff each change against the previous change. This defines an order
in which the patchfiles must be applied. This option makes the most
sense in my head.
Is one of these three methods the "correct" way in which multiple
patches should be managed?
Take care,
Seth McDonald.
[0] <https://guide.macports.org/chunked/development.patches.html>
--
E9D1 26A5 F0D4 9DF7 792B C2E2 B4BF 4530 D39B 2D51
More information about the macports-dev
mailing list