Download raw body.
small enhancement for sdiff(1) interactive merge
I found myself scripting "sdiff -o" as part of a regression test,
in order to merge files with merge conflicts resolved.
In some situations there is no clear winner of one side of the
diff over the other, and both sides are needed in the merge result.
I can already ask sdiff to edit both sides concatenated in an editor
via the "e b" option. This is fine in interactive mode, but it is
unsuitable for scripting.
With the patch below sdiff allows both sides to be chosen in either
order without a requirement to run the lines through an editor.
Which might also be useful during sysmerge(8) occasionally.
ok?
M usr.bin/sdiff/sdiff.1 | 4+ 0-
M usr.bin/sdiff/sdiff.c | 23+ 0-
2 files changed, 27 insertions(+), 0 deletions(-)
commit - c05afcd07bace06edf17cd055a3e952f274ff4ef
commit + 3aae2d190004fbbb6f79a59efb3cfa99f3665c6a
blob - 4cb68c11c8f8143d342de80a8fa9381639860805
blob + 9c113e1d17aa7ed72850eae34568079d112c6a2f
--- usr.bin/sdiff/sdiff.1
+++ usr.bin/sdiff/sdiff.1
@@ -60,6 +60,10 @@ The commands are as follows:
Choose left set of diffs.
.It Cm r | 2
Choose right set of diffs.
+.It Cm b l | b 1
+Choose both, left set of diffs first.
+.It Cm b r | b 2
+Choose both, right set of diffs first.
.It Cm s
Silent mode \(en identical lines are not printed.
.It Cm v
blob - 284aca5ddbb142959b4585f5f1d9d0804f42a2f8
blob + f0a652f5154c92914db1633ec421b2968208c630
--- usr.bin/sdiff/sdiff.c
+++ usr.bin/sdiff/sdiff.c
@@ -448,6 +448,27 @@ prompt(const char *s1, const char *s2)
;
switch (*p) {
+ case 'b':
+ /* Skip `b'. */
+ ++p;
+
+ /* Choose both columns in either order. */
+ if (*p == 'l' || *p == '1') {
+ if (s1 != NULL)
+ fprintf(outfp, "%s\n", s1);
+ if (s2 != NULL)
+ fprintf(outfp, "%s\n", s2);
+ } else if (*p == 'r' || *p == '2') {
+ if (s2 != NULL)
+ fprintf(outfp, "%s\n", s2);
+ if (s1 != NULL)
+ fprintf(outfp, "%s\n", s1);
+ } else
+ goto USAGE;
+
+ /* End of command parsing. */
+ break;
+
case 'e':
/* Skip `e'. */
++p;
@@ -1046,6 +1067,8 @@ int_usage(void)
"er:\tedit right diff\n"
"l | 1:\tchoose left diff\n"
"r | 2:\tchoose right diff\n"
+ "bl|b1:\tchoose both, left diff first\n"
+ "br|b2:\tchoose both, right diff first\n"
"s:\tsilent mode--don't print identical lines\n"
"v:\tverbose mode--print identical lines\n"
"q:\tquit");
small enhancement for sdiff(1) interactive merge