textutil::patch(n)
β¨ NAME β¨
textutil::patch β applying uni-diff patches to whole directory trees π¦
πΈ 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 π
okay so listen, this package is literally just one command, and what that one command does is take a patch in unified format β you know the one, [https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html] β and apply it to a directory tree. one job. does it well. periodt. π
::textutil::patch::apply basedirectory striplevel patch reportcmd
Applies the patch β and yes bestie, text of the path, not file β to the files sitting inside basedirectory, using the striplevel you told it to use. and the result of the whole command? the empty string. that's it. that's the tea. π΅
the striplevel argument is equivalent to option -p of the patch command. same energy, same meaning, iykyk.
if the patch doesn't parse, errors get thrown, and nothing is done to the files in basedirectory β like, nothing at all, it bails before touching anything. iconic behaviour honestly. β
Every single activity that happens while the patch is being applied β including when it just cannot apply a hunk β gets reported through the command prefix reportcmd instead of being shouted at you some other way. Files with problems are left unchanged. but heads up, because this is the part people miss: that does not prevent changes to files with no problems, before and after the problematic file(s). so yeah, the good files still get their glow-up. π
the command prefix gets called in 3 possible forms:
{*}reportcmd apply filenameβ the caller is starting work on filefname, applying every hunk that got collected for that file. π{*}reportcmd fail filename hunk expected seenβ applying hunk numberhunkof filefilenamefailed. the command expected to find the textexpected, and instead it sawseen. awkward. π{*}reportcmd fail-already filename hunkβ applying hunk numberhunkof filefilenamefailed. the command believes that this hunk has already been applied to the file. it's giving "girl we've been here before". π
π«Ά BUGS, IDEAS, FEEDBACK π«Ά
ngl, this document β and the package it describes β will undoubtedly contain bugs and other problems. it's software, bestie. please report them in the category textutil of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. and while you're at it, report any ideas for enhancements you have for the package and/or the documentation too β we love a glow-up suggestion. β¨
when you're proposing code changes, please hand over unified diffs, i.e. the output of diff -u. no cap, that's the format. π₯
also note: attachments are strongly preferred over inlined patches. to attach something, go to the Edit form of the ticket right after you create it, then use the left-most button in the secondary navigation bar. easy. π¦
π KEYWORDS π
diff -ruN, diff, unified format, fossil, git, patch, unified format diff
π CATEGORY π
Text processing
and that's the whole page, bestie π this one came to you from tcllib, version 0.2 β go forth and patch responsibly ππ«Άβ¨
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms