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