git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Programmatic patches (transform commits)

From
MFMark Fulton <mfulton26@gmail.com>
Date
Aug 18, 2022, 15:21 UTC
Message-ID
<CAED_RJPh28o8bFsBEEzAYvp1DXhff2JWiTk3zHh3VbaHZephgg@mail.gmail.com>

Is there a way to commit a transform script that programmatically applies file changes rather than committing the file changes directly?

e.g. Imagine in a large repository that a contributor wants to replace certain instances of "abc" with "xyz". A transform script might be like the following:

```sh #!/bin/sh

sed -i 's/abc/xyz/g' $(find .) ```

Applying such a "programmatic patch" will potentially edit many files. Doing a code review on such a change is error prone due to authors resolving merge conflicts manually, etc. while reviewing the patch in some circumstances is much easier (especially tools for specifically this type of file transformations are used to make it easy to parse code, traverse abstract syntax trees, make edits, etc.).

Does anything like this exist today? Depending on the implementation I could see there being cross-platform support challenges but maybe there is something that already exists to assist with this which I can learn about.

As an alternative to making this part of Git I can see tools like GitHub Actions being used to look for commits of "programmatic patch" files, pick those up, run them, and commit and push the change but having a solution for this as part of Git itself would make it independent of GitHub and more reusable, etc.

Next: Ævar Arnfjörð Bjarmason
Message 1 of 3 in “Programmatic patches (transform commits)”
  1. Mark FultonAug 18, 2022
  2. Ævar Arnfjörð BjarmasonAug 18, 2022
  3. Johannes SchindelinAug 19, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.