Apply patches in a deterministic order - #131
Merged
Tobias-Fischer merged 1 commit intoAug 6, 2026
Merged
Conversation
The patches of a package were collected with glob.glob(), which returns the directory entries in filesystem order. Two patches of the same package could therefore be listed in either order across machines and runs, so regenerating the recipes produced a spurious diff and, more importantly, the patches could be applied in the wrong order. Sort the glob result, so the patches of a package are always applied in the lexicographic order of their file names, which is what the usual 0001-/0002- prefixes are meant to express. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
diegoferigo-rai
marked this pull request as ready for review
August 6, 2026 16:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The patches of a package are collected with
glob.glob(), which returns the directory entries in filesystem order.Two patches of the same package can therefore end up in either order depending on the machine and on the run. That produces a spurious diff every time the recipes are regenerated, and, more importantly, it can apply a
0002-patch before the0001-one, which is exactly the order those prefixes are meant to express.I hit this with two patches on the same package: regenerating the recipes on a different machine swapped the two entries in the generated
recipe.yaml.Sorting the glob result is enough to make the order deterministic and lexicographic.
Tested
pyteston the repo: 113 passed.source.patcheslist is now stable.