textutil::patch(3tcl)
β¨ textutil::patch β¨
okay bestie, so this is a page from the tcllib manual, section 3tcl, and it's about the textutil::patch thing. literally the whole vibe is: Application of uni-diff patches to directory trees. yes, like patch but it's a Tcl package and it does trees. we love that for us π¦
πΈ SYNOPSIS πΈ
package require Tcl 8.5 9
package require textutil::patch ?0.2?
::textutil::patch::apply basedirectory striplevel patch reportcmd
{*}reportcmd apply filename
{*}reportcmd fail filename hunk expected seen
{*}reportcmd fail-already filename hunk
π DESCRIPTION π
so this package gives you literally one single command and what it does is apply a patch in unified format β the details on that format live over here: [https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html] β and it applies it to a directory tree. that's the whole thing. no cap. π
β¨ ::textutil::patch::apply basedirectory striplevel patch reportcmd
okay so this one applies the patch (heads up, it wants the text of the path, not the file) to the files sitting inside basedirectory, and it does it using the striplevel you handed it. and the result of the command? the empty string. that's it. iconic behaviour honestly.
about striplevel β it's the same energy as the -p option of the patch command. same thing, different font. π
if the patch doesn't parse, it throws errors, and nothing happens to the files in basedirectory. like, not a single one. safe. periodt.
every activity that goes down while the patch is being applied β including the fact that it couldn't apply a hunk β gets reported through the command prefix reportcmd instead of screamed at you directly. files that have problems get left exactly how they were. but β and this is the important bit β that does not stop changes from landing on files with no problems, both before and after the problematic file(s). so like, it's not a full rollback situation, just so you know. π
so reportcmd gets called in 3 possible forms:
{*}reportcmd apply filenameβ the caller is starting operation on filefname, applying all the hunks it collected for that file. go off king π{*}reportcmd fail filename hunk expected seenβ applying hunk numberhunkof filefilenamefailed. the command expected to find the textexpected, and instead it sawseen. the audacity π{*}reportcmd fail-already filename hunkβ applying hunk numberhunkof filefilenamefailed, because the command is pretty sure this hunk has already been applied to the file. it's giving dΓ©jΓ vu π«Ά
π BUGS, IDEAS, FEEDBACK π
bestie, be real β this doc and the package it describes? yeah they're gonna have bugs and other problems. no notes, it's just how it is. please report them in the textutil category of the Tcllib Trackers: [http://core.tcl.tk/tcllib/reportlist]. and if you've got ideas for enhancements for the package and/or the docs, drop those there too, we're obsessed with feedback. β¨
if you're proposing code changes, please send unified diffs β i.e. the output of diff -u. that's the vibe. π¦
and one more thing: attachments are strongly preferred over inlined patches. you can attach stuff by going to the Edit form of the ticket right after creating it, then hitting the left-most button in the secondary navigation bar. iykyk π
π₯ KEYWORDS π₯
diff -ruN, diff, unified format, fossil, git, patch, unified format diff
π CATEGORY π
Text processing
and that's the whole page, bestie!! this is from tcllib, version 0.2, dated back in the day, and it lives at textutil::patch(3tcl). slay, go apply some patches responsibly. mwah ππ
π¦ where this page comes from
- debian trixie: tcllib 2.0+dfsg-4 Β· Tcl
- ubuntu questing: tcllib 2.0+dfsg-4
- ubuntu resolute: tcllib 2.0+dfsg-5 Β· Tcl
- ubuntu stonking: tcllib 2.0+dfsg-6 Β· Tcl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms