{"id":26040245,"url":"https://github.com/cbilz/patch","last_synced_at":"2026-02-13T08:10:32.285Z","repository":{"id":278418519,"uuid":"935100052","full_name":"cbilz/patch","owner":"cbilz","description":"Zig package for applying patches to files","archived":false,"fork":false,"pushed_at":"2025-03-06T14:25:47.000Z","size":358,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T01:13:18.832Z","etag":null,"topics":["build-system","diff","git","patch","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cbilz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-18T22:46:46.000Z","updated_at":"2025-03-06T14:25:50.000Z","dependencies_parsed_at":"2025-03-06T15:41:12.413Z","dependency_job_id":null,"html_url":"https://github.com/cbilz/patch","commit_stats":null,"previous_names":["cbilz/patch-step","cbilz/patch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbilz%2Fpatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbilz%2Fpatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbilz%2Fpatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbilz%2Fpatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbilz","download_url":"https://codeload.github.com/cbilz/patch/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137891,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-system","diff","git","patch","zig","zig-package"],"created_at":"2025-03-07T12:08:41.320Z","updated_at":"2026-02-13T08:10:32.231Z","avatar_url":"https://github.com/cbilz.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Zig package for applying patches to files\n\nWork in progress. Feedback is welcome!\n\n## Goal\n\nThis project will provide a Zig package for applying diffs in Git and unified\nformats to directory trees or individual files. It will be free of system\ndependencies by default while allowing integration with Git or GNU patch when\nneeded.\n\n## Motivation\n\nOne use case for this package will be to enable building C and C++ projects from\npristine tarballs while applying patches for the host system, bug fixes, or\nother reasons. This approach is more transparent to dependents compared to\nbuilding from a forked version of the upstream source.\n\n## Rationale\n\nThe package will expose **outputs as artifacts** (via `b.addNamedLazyPath(...)`)\nand accept **inputs as options** (via `b.option(LazyPath, ...)`), following [the\nintended\napproach](https://github.com/ziglang/zig/pull/18778#issuecomment-1925660119).\n\nInternally, the package will use **`std.Build.Step.Run`** instead of custom build\nsteps in preparation for the [separation of the build runner from the configure\nprocess](https://github.com/ziglang/zig/issues/20981).\n\nBy default, the package will use its **own `patch` implementation** to help\ndependents reduce their system dependencies. Every system dependency removed\nmakes it easier to onboard new contributors.\n\nHowever, there will also be options (via `b.systemIntegrationOption(...)`) to\n[**use the system packages**](https://github.com/ziglang/zig/pull/18778) Git or\nGNU patch when appropriate, such as when packaging or when build times or\ncompatibility are of concern.\n\n## Next steps\n\n1. Complete implementation and review resource management:\n    - Ensure a small number of file descriptors are open at any time.\n    - Delete temporary directories on exit.\n    - Clean up output directories in case of errors.\n2. Create a test build step.\n3. Add additional test cases to check the following behaviors:\n    - Correct handling of quote wrapped paths.\n    - Correct handling of patches with junk text between a hunk and the next\n      header.\n    - Rejection of invalid paths (both wrapped and unwrapped).\n    - Rejection of empty patches.\n    - Rejection of patches without any headers.\n    - Rejection of invalid headers.\n    - Rejection of invalid hunks.\n    - Rejection of multiple changes to the same file within a single Git patch.\n4. Fix bugs.\n5. Implement the remaining characteristics described in the\n   [Rationale](#Rationale).\n6. Update this README.\n7. Tag a release.\n\n## Requirements\n\nUses Zig 0.14.0-dev.3462+edabcf619.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbilz%2Fpatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbilz%2Fpatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbilz%2Fpatch/lists"}