2 * wiggle - apply rejected patches
4 * Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au>
5 * Copyright (C) 2010-2013 Neil Brown <neilb@suse.de>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program.
22 * Email: <neilb@suse.de>
26 * Options and help text for wiggle
35 #define VERS_DATE "2019-12-27"
38 char Version
[] = "wiggle " VERSION
" " VERS_DATE
" GPL-2+ http://neil.brown.name/wiggle/\n";
40 char short_options
[] = "xdmwlrho:iW123p::VRvqBb";
42 struct option long_options
[] = {
43 {"browse", 0, 0, 'B'},
44 {"extract", 0, 0, 'x'},
50 {"replace", 0, 0, 'r'},
52 {"version", 0, 0, 'V'},
53 {"reverse", 0, 0, 'R'},
54 {"verbose", 0, 0, 'v'},
57 {"output", 1, 0, 'o'},
58 {"no-ignore", 0, 0, 'i'},
59 {"show-wiggles",0, 0, 'W'},
60 {"ignore-blanks",0,0, 'b'},
61 {"no-backup", 0, 0, NO_BACKUP
},
62 {"self-test", 0, 0, SELF_TEST
},
63 {"report-wiggles", 0, 0, REPORT_WIGGLES
},
68 "Usage: wiggle --diff|--extract|--merge|--browse --lines|--words [--replace] files...\n";
71 "Wiggle - apply patches that 'patch' rejects.\n"
73 "Wiggle provides four distinct but related functions:\n"
74 "merge, diff, extract, and browse.\n"
75 "To get more detailed help on a function, select the function\n"
76 "before requesting help. e.g.\n"
77 " wiggle --diff --help\n"
80 " --extract -x : select 'extract' function.\n"
81 " --diff -d : select 'diff' function.\n"
82 " --merge -m : select 'merge' function (default).\n"
83 " --browse -B : select 'browse' function.\n"
85 " --words -w : word-wise diff and merge.\n"
86 " --lines -l : line-wise diff and merge.\n"
88 " --patch -p : treat last file as a patch file.\n"
89 " -1 -2 -3 : select which component of patch or merge to use.\n"
90 " --reverse -R : swap 'before' and 'after' for diff function.\n"
91 " --no-ignore -i : Don't ignore already-applied changes.\n"
92 " --show-wiggle -W : Report wiggles like conflicts with an extra stanza.\n"
94 " --help -h : get help.\n"
95 " --version -V : get version of wiggle.\n"
96 " --verbose -v : (potentially) be more verbose.\n"
97 " --quiet -q : don't print un-necessary messages.\n"
99 " --replace -r : replace first file with result of merger.\n"
100 " --no-backup : Never save original file (as name.porig).\n"
102 " --strip= -p : number of path components to strip from file names.\n"
104 "Wiggle needs to be given 1, 2, or 3 files. Any one of these can\n"
105 "be given as '-' to signify standard input.\n"
108 char HelpExtract
[] = "\n"
109 "wiggle --extract -[123] [--patch] merge-or-patch\n"
111 "The extract function allows one branch of a patch or merge file\n"
112 "to be extracted. A 'patch' is the output of 'diff -c' or 'diff -u'.\n"
113 "Either the before (-1) or after (-2) branch can be extracted.\n"
115 "A 'merge' is the output of 'diff3 -m' or 'merge -A'. Either the\n"
116 "first, second, or third branch can be extracted.\n"
118 "A 'merge' file is assumed unless --patch is given.\n"
121 char HelpDiff
[] = "\n"
122 "wiggle --diff [-wl] [-p12] [-R] file-or-patch [file-or-patch]\n"
124 "The diff function will report the differences and similarities between\n"
125 "two files in a format similar to 'diff -u'. With --word mode\n"
126 "(the default) word-wise differences are displayed on lines starting\n"
127 "with a '|'. With --line mode, only whole lines are considered\n"
128 "much like normal diff.\n"
130 "If one file is given is it assumed to be a patch, and the two\n"
131 "branches of the patch are extracted and compared. If two files\n"
132 "are given they are normally assumed to be whole files and are compared.\n"
133 "However if the --patch option is given with two files, then the\n"
134 "second is treated as a patch and the first or (with -2) second branch\n"
135 "is extracted and compared against the first file.\n"
137 "--reverse (-R) with cause diff to swap the two files before comparing\n"
141 char HelpMerge
[] = "\n"
142 "wiggle --merge [-wl] [--replace] file-or-merge [file-or-patch [file]]\n"
144 "The merge function is the primary function of wiggle and is assumed\n"
145 "if no function is explicitly chosen.\n"
147 "Normally wiggle will compare three files on a word-by-word basis and\n"
148 "output unresolvable conflicts in the resulting merge by showing\n"
149 "whole-line differences.\n"
150 "With the --lines option, the files are compared line-wise much\n"
151 "like 'merge'. With the (default) --words option, files are compared\n"
152 "word-wise and unresolvable conflicts are reported word-wise.\n"
154 "If --merge is given one file, it is treated as a merge (merge -A\n"
155 "output) and the three needed streams are extracted from it.\n"
156 "If --merge is given one file and -p, it is a patch which identifies\n"
157 "the files that should be patched.\n"
158 "If --merge is given two files, the second is treated as a patch\n"
159 "file and the first is the original file.\n"
160 "If --merge is given three files, they are each treated as whole files\n"
161 "and differences between the second and third are merged into the first.\n"
162 "This usage is much like 'merge'.\n"
165 char HelpBrowse
[] = "\n"
166 "wiggle --browse [-R] [--strip=n] [-p] [files]\n"
168 "The 'browse' function provides an interactive mode for browsing a\n"
169 "patch or set of patches. It allows the application of a patch to each\n"
170 "file to be inspected and will eventually allow limited editing to correct\n"
171 "mis-application of patches where wiggling was required, and where conflicts\n"
173 "If no files are given, a patch file is read from stdin\n"
174 "If one file is given with -p, it is treated as a patch file\n"
175 "If one file is given with a name ending .rej, it is treated as a reject for\n"
176 " a file with matching basename\n"
177 "Otherwise a single file is assumed to be a merge output with conflicts.\n"
178 "If two files are given, the second is a patch to apply to the first.\n"
179 "If three files are given then the difference between 2nd and 3rd is applied\n"