wiggle
Prevent computer from going idle (mouse movement)
TLDR
Apply changes from the patch file to the original file
Apply changes to the output file
Take any changes in file.rej that could not have been applied and merge them into a file
Extract one branch of a patch or merge file
Apply a patch and save the compared words to the output file
Display help about the merge function
SYNOPSIS
wiggle [options] [file...]
or
wiggle [options] patch_file [file...]
PARAMETERS
-p NUM
Strip NUM leading components from file names specified in the patch header.
-i PATCHFILE
Read the patch from PATCHFILE instead of standard input.
-o OUTFILE
Write output to OUTFILE instead of modifying the original file in place.
-v
Enable verbose mode, providing more information about the patching process and successful hunk applications.
-u
Treat the patch as a unified diff format. This is often the default for modern patches.
-N
Allow `wiggle` to create new files if the patch indicates a new file.
-F NUM
Set the fuzz factor to NUM. This specifies the number of lines `wiggle` can ignore when comparing context lines to find a match. A higher number allows for more deviation.
-R
Reverse the patch. Attempt to un-do the changes described in the patch file.
file...
One or more target files to apply the patch to. If not specified, `wiggle` attempts to determine the file(s) from the patch header.
DESCRIPTION
The `wiggle` command is a specialized utility designed to apply patches (generated by `diff`) even when the context lines in the patch do not exactly match the target file. Unlike the standard `patch` command, which might reject hunks with slight context discrepancies, `wiggle` attempts to "wiggle" the context lines up or down a few lines to find a matching location. This makes it invaluable for applying patches that were generated against a slightly different version of a file, or where line numbers have shifted due to unrelated changes.
It operates by searching for the best-fit location for each hunk, often requiring user confirmation for ambiguous matches. `wiggle` is particularly useful in development workflows where patches need to be applied across slightly diverging codebases, reducing the need for manual editing of patch files or target sources. It helps automate the application of non-exact patches, making it a powerful tool for maintaining and evolving software.
CAVEATS
`wiggle` is designed for minor context differences and is not a substitute for a full 3-way merge tool. It can sometimes make incorrect assumptions or apply a hunk to an unintended location if the context is too ambiguous or the differences are substantial. Users should always review the changes after using `wiggle` to ensure correctness. In cases of major divergence, manual intervention or a more robust merge utility is often required. Its "wiggling" capability is limited by the fuzz factor and the uniqueness of the context lines.
INTERACTIVE MODE
`wiggle` often prompts the user for confirmation when it finds multiple possible locations for a hunk or when a hunk's context is highly ambiguous, allowing the user to guide the patching process and select the correct application point.
LIMITATIONS
While powerful for minor positional mismatches, `wiggle` cannot resolve large structural changes, semantic conflicts, or conflicts arising from completely different logic in the code. It primarily deals with positional shifts of otherwise identical code blocks.
HISTORY
`wiggle` originated from the need to apply slightly "broken" patches, particularly common in open-source development where patches might be generated against subtly different versions of a codebase. It addresses a limitation of the standard `patch` utility, which is very strict about context matching. While `patch` has evolved with options like -F (fuzz factor), `wiggle` provides a more aggressive or interactive approach to resolving context mismatches, sometimes offering more fine-grained control or simply a different algorithm for finding the best match. It's often found bundled with `patch` utilities or as a separate specialized tool used by developers who frequently deal with community-contributed patches.