WIGGLE(1)
WIGGLE(1) β General Commands Manual π
NAME π
wiggle β apply rejected patches and perform word-wise diffs β¨
SYNOPSIS πΈ
wiggle [function] [options] file [files]
DESCRIPTION π¦
Okay so the main character function of wiggle is to apply a patch to a file, kinda like what patch(1) does. π
But here's the distinctive difference, bestie: wiggle will still try to apply a patch even if the "before" part of the patch doesn't match the target file perfectly. No cap. It does this by breaking the file and patch into words and finding the best alignment of words in the file with words in the patch. Once that alignment is found, any differences (word-wise) in the patch get applied to the file as best as possible. β¨
Also, wiggle will (in some cases) detect changes that have already been applied, and will ignore them. Lowkey iconic.
wiggle ensures that every change in the patch is applied to the target file somehow. If a particular change cannot be made in the file, the file is annotated to show where the change should be made, similar to the merge(1) program with the -A option. Each annotation contains 3 components: a portion of the original file where the change should be applied, a portion of the patch that couldn't be matched precisely in the file, and the text that should replace that portion of the patch. These are separated by lines containing precisely 7 identical characters, either <, |, =, or >, possibly followed by a descriptive word. So:
<<<<<<< found
Some portion of the original file
||||||| expected
text to replace
=======
text to replace it with
>>>>>>> replacement
This indicates that "text to replace" should be replaced by "text to replace it with" somewhere in the portion of the original file. However, wiggle was not able to find a place to make this change. π
wiggle can also produce conflict reports showing only the words that are involved rather than showing whole lines. In this case the output looks like:
<<<---original|||old===new--->>>
One possible usage of wiggle is to run patch to apply some patch, and to collect a list of rejects by monitoring the error messages from patch. Then for each file for which a reject was found, run:
wiggle --replace originalfile originalfile.rej
Finally each file must be examined to resolve any unresolved conflicts, and to make sure the applied patch is semantically correct. Periodt. π
Alternately, the original patch file can be fed to the browse mode as:
wiggle -B < patchfile
This will allow the changes and conflicts to be inspected and, to some extent, modified; and then the results can be saved. β¨
OPTIONS π
The following options are understood by wiggle. Some of these are explained in more detail in the following sections on MERGE, DIFF, EXTRACT, and BROWSE. π
-m,--mergeβ Select the "merge" function. This is the default function. π-d,--diffβ Select the "diff" function. This displays the differences between files. This can be given after--browse(see below) in which case a patch or diff of two files can be viewed without the originals. π¦-x,--extractβ Select the "extract" function. This extracts one branch of a patch or merge file. π-B,--browseβ Select the "browse" function. This is similar to "merge" (or "diff") only with a different presentation. Instead of the result simply being sent to standard output, it is presented using an ncurses-based GUI so that each hunk of the patch can be examined to understand what conflicts where involved and what needed to be ignored in order of the patch to be wiggled in to place. π-w,--wordsβ Request that all operations and display be word based. This is the default for the "diff" function. β¨--non-spaceβ Request that words be defined as sequences of non-white-space. Without this flag words are sequences of alphanumerics or single non-white-space characters. This flag is automatically enabled ifwiggleneeds to compare two files which both have more than 50,000 words. π₯-l,--linesβ Request that all operations and display be line based. π-b,--ignore-blanksβ De-emphasise white space (space, tab, and newline) is determining differences and changes.
Normally white space is treated like a word which can be matched or changed by a patch. When this flag is in force, white space serves only as a separator between other words and is not matched itself. The effect of this is that changes in the amount of white space are not treated as significant.
To be precise, any white space is combined with the preceding word or, in the case of leading space on a line, with the following word. However it is not involved in any comparisons of that word. If a patch deletes a word, the attached white space is deleted as well. If a patch adds a word, the attached white space is added as well.
An empty line, or one that contains only blanks, will be treated as a single word that will match any other blank line, no matter how many spaces it has.
-b has no effect in --line mode. π«Ά
-p,--patchβ Treat the last named file as a patch instead of a file (with--diff) or a merge (--extract). In merge or browse mode,-prequires there be exactly one file which is a patch and which can contain patches to multiple files. The patches are merged into each file. When used in merge mode, this usage requires the--replaceoption as writing lots of merged files to standard-out is impractical.
When processing a multi-file patch, -p can be followed by a numeric argument indicating how many file name components should be stripped from files named in the patch file. If no numeric argument is given, wiggle will deduce an appropriate number based what files are present in the filesystem. πΈ
-r,--replaceβ Normally the merged output is written to standard-output. With--replace, the original file is replaced with the merge output. In browse mode, this instructswiggleto always save the resulting merge when exiting. π--no-backupβ Normally when an original file is replaced with the merged result, that file is renamed to have a.porigextension, so that it is preserved. If you don't want to keep the original, use this option to suppress the backup. π-o,--output=β Rather than writing the result to stdout or to replace the original file, this requests that the output be written to the given file. This is only meaningful with--mergeor--browsewhen given a single merge to browse.
This option overrides -r. π
-R,--reverseβ When used with the diff function, swap the files before calculating the differences. When used with the merge or browse functions,wiggleattempts to revert changes rather than apply them. π¦--shortestβ If the files being compared are large, it can take a long time to isolate the differences. Normallywigglewill give up on perfection if a step takes more than 20msec. To over-ride this and always find the shortest edit-distance between two files, use the--shortestoption. β±οΈ-i,--no-ignoreβ Normallywigglewill ignore changes in the patch which appear to already have been applied in the original. With this flag those changes are reported as conflicts rather than being ignored. π₯-W,--show-wigglesβ When used with--merge, conflicts that can be wiggled into place are reported as conflicts with an extra stanza which shows what the result would be if this flag had not been used. The extra stanza is introduce with a line containing 7 ampersand (&) characters thus:
<<<<<<< found
Some portion of the original file
||||||| expected
text to replace
=======
text to replace it with
&&&&&&& resolution
Text that would result from a successful wiggle
>>>>>>> replacement
--report-wigglesβ If a merge is successful in applying all changes, it will normally exit with a success status (0), only reporting failure (1) if a conflict occurred and was annotated. With--report-wiggleswigglewill also report failure if any changes had to be wiggled in. This can be useful whenwiggleis used for automatic merges as withgit. If any wiggles happen,gitwill report the failure, and the results can be examined to confirm they are acceptable. π-h,--helpβ Print a simple help message. If given after one of the function selectors (--merge,--diff,--extract,--browse) help specific to that function is displayed. π-V,--versionβ Display the version number ofwiggle. β¨-v,--verboseβ Enable verbose mode. Currently this makes no difference. π-q,--quietβ Enable quiet mode. This suppresses the message from the merge function when there are unresolvable conflicts. π€«
WORDS π¦
wiggle can divide a text into lines or words when performing it's tasks. A line is simply a string of characters terminated by a newline. A word is either a maximal contiguous string of alphanumerics (including underscore), a maximal contiguous string of space or tab characters, or any other single character. β¨
MERGE π
The merge function modifies a given text by finding all changes between two other texts and imposing those changes on the given text. π
Normally wiggle focuses on which words have changed so as to maximise the possibility of finding a good match in the given text for the context of a given change. However it can consider only whole lines instead. πΈ
wiggle extracts the three texts that it needs from files listed on the command line. Either 1, 2, or 3 files may be listed, and any one of them may be a lone hyphen signifying standard-input. π
If one file is given and the -p option is not present, the file is treated as a merge file, i.e. the output of "merge -A" or "wiggle". Such a file implicitly contains three streams and these are extracted and compared. β¨
Okay so boom, continuing right where we left off, bestie π
If you hand it two files, the first one is just the primary text, and the second one gets treated as a patch file β so like, the output of diff -u or diff -c, or a .rej file from patch β and the other two texts get extracted from that patch. Cute, right? β¨
If you give it one file together with the -p option, that file is treated as a patch file that literally contains the names of the files it patches. In that case, multiple merge operations can happen at once, and each one takes one stream from a file named inside the patch, and the other two streams from the patch itself. The --replace option is required here, and the results get written back to the target files. No take-backs π
And finally, if you list three files, they're taken to contain the given text plus the two other texts, in order. That's it, that's the trio πΈ
Normally the result of the merge goes straight to standard-output. If you pass the -r flag though, the output gets written to a file that replaces the original given file. In that case the original file normally gets renamed with a .porig suffix (that's "patched original" β makes total sense if you first use patch to apply a patch, and then use wiggle to wiggle the rejects in π«Ά). You can suppress that with the --no-backup uption. (yes bestie that's literally how it's spelled in the original, we don't touch it π)
Also, if you give the -o option with a file name, the output goes to that file. And in that case, no backup gets created. Iconic, honestly.
Now for exit statuses, the moment you've been waiting for π
If no errors occur (like file access errors or whatever), wiggle exits with a status of 0 if all changes were successfully merged. It exits with a status of 1 and a brief message if any changes could not be fully merged and were instead inserted as annotations. BUT β and this is the plot twist β if either --report-wiggles or --show-wiggles was given, then wiggle also exits with status 1 if any changes had to be wiggled in, even though that was successful. Slay but noted π
The merge function can operate in three different modes when it comes to lines vs words.
- With the
--linesoption, whole lines are compared, and any conflicts are reported as whole lines that need to be replaced. - With the
--wordsoption, individual words are compared, and any conflicts are reported covering just the words affected. This uses the<<<|||===>>>conflict format. - Without either of those options, it takes a hybrid approach: individual words are compared and merged, but when a conflict shows up, the whole surrounding line gets reported as being in conflict.
wiggle will make sure that every change between the two other texts is reflected in the result of the merge somehow. There are four different ways a change can be reflected:
- If a change converts A to B and A is found at a suitable place in the original file, it gets replaced with B. This includes the possibility that B is empty β but not that A is empty.
- If a change is found that simply adds B, and the text immediately preceding and following the insertion are found adjacent in the original file in a suitable place, then B gets inserted between those adjacent texts.
- If a change is found which changes A to B and this appears (based on context) to align with B in the original, then it's assumed that this change has already been applied, and the change is ignored. When this happens, a message reflecting the number of ignored changes gets printed by
wiggle. This optimisation can be suppressed with the-iflag. - If a change is found that doesn't fit any of the above possibilities, then a conflict is reported, as described earlier.
π DIFF π
The diff function is there primarily so you can inspect the alignments that wiggle calculated between texts, and that it uses for performing a merge. Very "let me show you my work" of it β¨
The output of the diff function is similar to the unified output of diff. However β while diff doesn't output long stretches of common text, wiggle's diff mode outputs everything. No secrets here, bestie.
When calculating a word-based alignment (which is the default), wiggle may need to show these word-based differences. It does this using an extension to the unified-diff format. If a line starts with a vertical bar, then it may contain sections surrounded by special multi-character brackets. The brackets <<<++ and ++>>> surround added text, while <<<-- and -->>> surround removed text. Little bracket besties holding hands π«Ά
You can give wiggle the two texts to compare in one of three ways:
- If only one file is given, then it's treated as a patch, and the two branches of that patch are compared. This effectively lets a patch be refined from a line-based patch into a word-based patch. Glow-up arc π
- If two files are given, then they're normally assumed to be simple texts to be compared.
- If two files are given along with the
--patchoption, then the second file is assumed to be a patch, and either the first (with-1) or the second (with-2) branch is extracted and compared with text found in the first file.
That last option makes wiggle apply a "best-fit" algorithm for aligning patch hunks with the file before computing the differences. This algorithm is used when merging a patch with a file, and you can see its value by comparing the difference produced this way with the difference produced by first extracting one branch of a patch into a file, and then computing the difference of that file with the main file. Yeah, it's giving "trust the process" π
π§² EXTRACT π§²
The extract function of wiggle simply exposes the internal functionality for extracting one branch of a patch or a merge file. It's like the backstage pass of the whole operation π
Precisely one file should be given, and it'll be assumed to be a merge file β unless --patch is given, in which case a patch is assumed.
The choice of branch is made by providing one of -1, -2, or -3, with obvious meanings. Pick your fighter π
π₯οΈ BROWSE π₯οΈ
The browse function of wiggle presents the result of a merge β or, with -d, a diff β in a text-based GUI that you can navigate with keystrokes similar to vi(1) or emacs(1). Main character energy, but make it terminal π
The browser lets each of the two or three streams be viewed individually, with colours used to highlight different sorts of text β green for added text, red for deleted text, etc. It can also show the patch by itself, the full result of the merge, or the merge and the patch side-by-side. A whole aesthetic β¨
The browser provides a number of context-sensitive help pages which you can access by typing '?'.
The top right of the GUI reports the type of text under the cursor, which is also indicated by the colour of the text. The options are Unchanged, Changed, Unmatched, Extraneous, AlreadyApplied and Conflict. If the meanings of these are clear, a little experimentation should help. Vibes-based learning fr fr πΈ
A limited amount of editing is permitted while in browse mode. Currently, text that is unwanted can be discarded with x. This will convert a Conflict or Change to Unchanged, and an Unmatched to Changed (which effectively changes it to the empty string). Similarly, a text can be marked as wanted with c. This will convert a Conflict or Extraneous to Changed. Using the same key again will revert the change. Undo culture, we love to see it π
Finally, the uppercase X will revert all changes on the current line.
To make more sweeping changes, you can use v, which runs an editor β preferring $VISUAL or $EDITOR if they're set in the environment. Respect the environment variables, bestie π
If you make any changes, then wiggle will ask you if you want to save the changes, even if --replace was not given. It just wants to be sure π₯Ί
β οΈ WARNING β οΈ
Caution should always be exercised when applying a rejected patch with wiggle. When patch rejects a patch, it does so for a good reason. Even though wiggle may be able to find a believable place to apply each textual change, there is no guarantee that the result is correct in any semantic sense. The result should always be inspected to make sure it's correct.
Bestie, I am so serious about this one. Believable β correct. Always look at the result. No cap. π¨
π EXAMPLES π
wiggle --replace file file.rej
This is the normal usage of wiggle and will take any changes in file.rej that patch could not apply, and merge them into file. The classic π
wiggle -dp1 file file.rej
This will perform a word-wise comparison between the file and the before branch of the diff in file.rej and display the differences. This allows you to see where a given patch would apply. Detective mode π
wiggle --merge --help
Get help about the merge function of wiggle. Ask for directions, it's fine π«Ά
wiggle --browse --patch update.patch
Parse the update.patch file for patches and present a list of patched files which can be browsed to examine each patch in detail. So organised of it β¨
wiggle can be integrated with git so that it's used as the default merge tool and diff tool. You can achieve this by adding the following lines to .gitconfig in the user's home directory:
[merge "wiggle"]
name = "Wiggle flexible merging"
driver = wiggle -o %A %A %O %B
recursive = binary
[merge]
tool = wiggle
[mergetool "wiggle"]
cmd = wiggle -B -o $MERGED $LOCAL $BASE $REMOTE
[difftool "wiggle"]
cmd = wiggle -Bd $LOCAL $REMOTE
This will make git mergetool and git difftool use wiggle. Glow-up for your whole workflow π
If you want git to always use wiggle for merges (which may be dangerous π), you can add:
* merge=wiggle
to an appropriate gitattributes file such as $HOME/.config/git/attributes.
π¬ QUOTE π¬
The name of wiggle was inspired by the following quote.
The problem I find is that I often want to take (file1+patch) -> file2, when I don't have file1. But merge tools want to take (file1|file2) -> file3. I haven't seen a graphical tool which helps you to wiggle a patch into a file. -- Andrew Morton - 2002
Honestly? A visionary. π
π SHORTCOMINGS π
wigglecannot read the extended unified-diff output that it produces for--diff --words.wigglecannot read the word-based merge format that it produces for--merge --words.wiggledoes not understand unicode and so will treat all non-ASCII characters much the same as it treats punctuation β it will treat each one as a separate word. The browser will not display non-ASCII characters properly.
Yeah bestie, it can't read its own homework in a couple of cases. We still love it. π
π AUTHOR π
Neil Brown at Computer Science and Engineering at The University of New South Wales, Sydney, Australia; and later at SUSE, still in Sydney, Australia. Legend behaviour, fr fr π
π SEE ALSO π
patch(1), diff(1), merge(1), wdiff(1), diff3(1), git-config(1), gitattributes(5).
And that's a wrap on WIGGLE(1) β this whole page is from v1.3, so go forth and wiggle those rejects into place, bestie. Inspect your results, respect the warning, and stay iconic π
β¨π¦
π¦ where this page comes from
- alpine 3.24: wiggle-doc 1.3-r0 Β· GPL-2.0-or-later
- debian trixie: wiggle 1.3-1 Β· GPL-2.0-or-later
- epel 9: wiggle 1.3-1.el9 Β· GPLv2+
- fedora 43: wiggle 1.3-5.fc43 Β· GPL-2.0-or-later
- fedora 44: wiggle 1.3-6.fc44 Β· GPL-2.0-or-later
- nixos 26.05: wiggle 1.3
- nixpkgs unstable: wiggle 1.3
- ubuntu noble: wiggle 1.3-1 Β· GPL-2.0-or-later
- ubuntu questing: wiggle 1.3-1
- ubuntu resolute: wiggle 1.3-1build1 Β· GPL-2.0-or-later
- ubuntu stonking: wiggle 1.3-1build1 Β· GPL-2.0-or-later
- Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au>
- Copyright (C) 2010-2013 Neil Brown <neilb@suse.de>
- Copyright (C) 2018-2020 Neil Brown <neil@brown.name>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms