commit wiggle for openSUSE:Factory
Hello community, here is the log from the commit of package wiggle for openSUSE:Factory checked in at 2019-12-27 14:01:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/wiggle (Old) and /work/SRC/openSUSE:Factory/.wiggle.new.6675 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "wiggle" Fri Dec 27 14:01:11 2019 rev:21 rq:759670 version:1.2 Changes: -------- --- /work/SRC/openSUSE:Factory/wiggle/wiggle.changes 2018-08-24 17:03:56.294059587 +0200 +++ /work/SRC/openSUSE:Factory/.wiggle.new.6675/wiggle.changes 2019-12-27 14:01:13.564885663 +0100 @@ -1,0 +2,12 @@ +Fri Dec 27 10:53:41 UTC 2019 - Michael Vetter <mvetter@suse.com> + +- Update to 1.2: + * Fix format overflow and truncation warnings with GCC-8. + * Fix array bounds error in diff_path + * extract: allow blank lines in unified diffs + * Add --no-backup option + * Preserve file mode when using doing --merge --replace + * Fix very minor memory leaks in do_merge() + * Several small fixes + +------------------------------------------------------------------- Old: ---- wiggle-1.1.tar.gz New: ---- wiggle-1.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ wiggle.spec ++++++ --- /var/tmp/diff_new_pack.IAG8jN/_old 2019-12-27 14:01:14.208885962 +0100 +++ /var/tmp/diff_new_pack.IAG8jN/_new 2019-12-27 14:01:14.208885962 +0100 @@ -1,7 +1,7 @@ # # spec file for package wiggle # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,17 +12,17 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: wiggle -Version: 1.1 +Version: 1.2 Release: 0 Summary: A Tool for Applying Patches with Conflicts License: GPL-2.0-or-later Group: Productivity/Text/Utilities -URL: http://neil.brown.name/wiggle/ +URL: https://neil.brown.name/wiggle/ Source0: http://neil.brown.name/wiggle/%{name}-%{version}.tar.gz BuildRequires: ncurses-devel ++++++ wiggle-1.1.tar.gz -> wiggle-1.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/ChangeLog new/wiggle-1.2/ChangeLog --- old/wiggle-1.1/ChangeLog 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/ChangeLog 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ - - - Don't use --quiet in dotest as it is a Debian specific extension - to /usr/bin/time - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/DOC/Algorithm new/wiggle-1.2/DOC/Algorithm --- old/wiggle-1.1/DOC/Algorithm 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/DOC/Algorithm 2019-12-27 06:12:38.000000000 +0100 @@ -23,7 +23,7 @@ your work. Wiggle takes a different approach. Finding where the snakes cross -seemed awkward to me, and having two blocks of similiar but not +seemed awkward to me, and having two blocks of similar but not identical code (one to search forward, one to search backwards) didn't appeal at all. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/ReadMe.c new/wiggle-1.2/ReadMe.c --- old/wiggle-1.1/ReadMe.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/ReadMe.c 2019-12-27 06:12:38.000000000 +0100 @@ -29,10 +29,10 @@ #include "wiggle.h" #ifndef VERSION -#define VERSION "1.1" +#define VERSION "1.2" #endif #ifndef VERS_DATE -#define VERS_DATE "2017-09-28" +#define VERS_DATE "2019-12-27" #endif char Version[] = "wiggle " VERSION " " VERS_DATE " GPL-2+ http://neil.brown.name/wiggle/\n"; @@ -58,6 +58,7 @@ {"no-ignore", 0, 0, 'i'}, {"show-wiggles",0, 0, 'W'}, {"ignore-blanks",0,0, 'b'}, + {"no-backup", 0, 0, NO_BACKUP }, {"self-test", 0, 0, SELF_TEST}, {"report-wiggles", 0, 0, REPORT_WIGGLES}, {0, 0, 0, 0} @@ -96,6 +97,7 @@ " --quiet -q : don't print un-necessary messages.\n" "\n" " --replace -r : replace first file with result of merger.\n" +" --no-backup : Never save original file (as name.porig).\n" "\n" " --strip= -p : number of path components to strip from file names.\n" "\n" @@ -119,7 +121,7 @@ char HelpDiff[] = "\n" "wiggle --diff [-wl] [-p12] [-R] file-or-patch [file-or-patch]\n" "\n" -"The diff function will report the differencs and similarities between\n" +"The diff function will report the differences and similarities between\n" "two files in a format similar to 'diff -u'. With --word mode\n" "(the default) word-wise differences are displayed on lines starting\n" "with a '|'. With --line mode, only whole lines are considered\n" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/bestmatch.c new/wiggle-1.2/bestmatch.c --- old/wiggle-1.1/bestmatch.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/bestmatch.c 2019-12-27 06:12:38.000000000 +0100 @@ -276,7 +276,7 @@ * in line-mode are interesting) and words that start with * and alphanumeric are interesting. This excludes spaces and * special characters in word mode - * Doing a best-fit comparision on only interesting words is + * Doing a best-fit comparison on only interesting words is * much faster than on all words, and is nearly as good */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/ccan/hash/hash.c new/wiggle-1.2/ccan/hash/hash.c --- old/wiggle-1.1/ccan/hash/hash.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/ccan/hash/hash.c 2019-12-27 06:12:38.000000000 +0100 @@ -9,7 +9,7 @@ the public domain. It has no warranty. You probably want to use hashlittle(). hashlittle() and hashbig() -hash byte arrays. hashlittle() is is faster than hashbig() on +hash byte arrays. hashlittle() is faster than hashbig() on little-endian machines. Intel and AMD are little-endian machines. On second thought, you probably want hashlittle2(), which is identical to hashlittle() except it returns two 32-bit hashes for the price of one. @@ -280,7 +280,7 @@ * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). + * noticeably faster for short strings (like English words). * * Not on my testing with gcc 4.5 on an intel i5 CPU, at least --RR. */ @@ -457,7 +457,7 @@ * rest of the string. Every machine with memory protection I've seen * does it on word boundaries, so is OK with this. But VALGRIND will * still catch it and complain. The masking trick does make the hash - * noticably faster for short strings (like English words). + * noticeably faster for short strings (like English words). * * Not on my testing with gcc 4.5 on an intel i5 CPU, at least --RR. */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/ccan/hash/hash.h new/wiggle-1.2/ccan/hash/hash.h --- old/wiggle-1.1/ccan/hash/hash.h 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/ccan/hash/hash.h 2019-12-27 06:12:38.000000000 +0100 @@ -34,7 +34,7 @@ * #include <stdio.h> * #include <string.h> * - * // Simple demonstration: idential strings will have the same hash, but + * // Simple demonstration: identical strings will have the same hash, but * // two different strings will probably not. * int main(int argc, char *argv[]) * { @@ -163,7 +163,7 @@ * #include <stdio.h> * #include <string.h> * - * // Simple demonstration: idential strings will have the same hash, but + * // Simple demonstration: identical strings will have the same hash, but * // two different strings will probably not. * int main(int argc, char *argv[]) * { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/diff.c new/wiggle-1.2/diff.c --- old/wiggle-1.1/diff.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/diff.c 2019-12-27 06:12:38.000000000 +0100 @@ -614,7 +614,8 @@ { int ap, bp; struct csl *csl = NULL; - if (a.list[0].start[0] != '\0' || + if (a.elcnt == 0 || b.elcnt == 0 || + a.list[0].start[0] != '\0' || b.list[0].start[0] != '\0') /* this is not a patch */ return diff(a, b); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/extract.c new/wiggle-1.2/extract.c --- old/wiggle-1.1/extract.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/extract.c 2019-12-27 06:12:38.000000000 +0100 @@ -118,12 +118,17 @@ skip_eol(&cp, end); if (state == 1 || state == 3) { char *f; - char buf[20]; + int slen; + /* Reserve enough space for 3 integers separated + * by a single space, and prefixed and terminated + * with a null character. + */ + char buf[(3*12)+1]; buf[0] = 0; chunks++; - sprintf(buf+1, "%5d %5d %5d", chunks, a, acnt); - memcpy(r1.body+r1.len, buf, 18); - r1.len += 18; + slen = sprintf(buf+1, "%5d %5d %5d", chunks, a, acnt)+1; + memcpy(r1.body+r1.len, buf, slen); + r1.len += slen; f = func; while (*f == ' ') f++; @@ -136,11 +141,16 @@ r1.body[r1.len++] = '\0'; } if (state == 2 || state == 3) { - char buf[20]; + int slen; + /* Reserve enough space for 3 integers separated + * by a single space, prefixed with a null character + * and terminated with a new line and null character. + */ + char buf[(3*12)+2]; buf[0] = 0; - sprintf(buf+1, "%5d %5d %5d\n", chunks, c, bcnt); - memcpy(r2.body+r2.len, buf, 20); - r2.len += 20; + slen = sprintf(buf+1, "%5d %5d %5d\n", chunks, c, bcnt)+2; + memcpy(r2.body+r2.len, buf, slen); + r2.len += slen; } if (state) func[0] = 0; @@ -189,6 +199,12 @@ cp++; copyline(&r2, &cp, end); bcnt--; + } else if (*cp == '\n') { + /* Empty line - treat like " \n" - a blank line in both */ + char *cp2 = cp; + copyline(&r1, &cp, end); + copyline(&r2, &cp2, end); + acnt --; bcnt--; } else { fprintf(stderr, "%s: bad unified patch at line %d\n", Cmd, lineno); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/merge2.c new/wiggle-1.2/merge2.c --- old/wiggle-1.1/merge2.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/merge2.c 2019-12-27 06:12:38.000000000 +0100 @@ -224,7 +224,10 @@ * might be after the last newline, if there * is one, or might be at the start */ - for (k = m[j].al; k > 0; k--) + for (k = m[j].al; k > 0; k--) { + if (m[j].a + k >= af.elcnt) + /* FIXME impossible!*/ + break; if (ends_line(af.list[m[j].a+k-1])) { if (firstk > m[j].al) firstk = k; @@ -234,6 +237,7 @@ break; } } + } if (k > 0) m[j].hi = k; else if (j == 0) @@ -380,7 +384,12 @@ if (m[i].type == End) break; } - for (k = 1; k < m[i].al; k++) + for (k = 1; k < m[i].al; k++) { + if (m[i].a + k >= af.elcnt) + /* FIXME this should be impossible, but + * it happened. + */ + break; if (words || ends_line(af.list[m[i].a+k])) { if (unmatched) unmatched--; @@ -389,6 +398,7 @@ if (extraneous) extraneous--; } + } } if (!show_wiggles) *wigglesp = wiggles; @@ -615,7 +625,7 @@ int offset) { int lines = 0; - while (len > 0) { + while (len > 0 && start < f->elcnt) { struct elmnt e = f->list[start]; printword(out, e); if (e.start[e.plen-1] == '\n' && diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/parse.c new/wiggle-1.2/parse.c --- old/wiggle-1.1/parse.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/parse.c 2019-12-27 06:12:38.000000000 +0100 @@ -296,7 +296,7 @@ if (of) fputc(c, of); - start = ftell(of ?: f); + start = ftell(of ? of : f); if (c == EOF) break; @@ -312,7 +312,7 @@ else pos = target2; } - end = ftell(of ?: f); + end = ftell(of ? of : f); if (pos > target2) end -= (pos - target2) - 1; plist = patch_add_file(plist, np, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/split.c new/wiggle-1.2/split.c --- old/wiggle-1.1/split.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/split.c 2019-12-27 06:12:38.000000000 +0100 @@ -125,9 +125,13 @@ { int cnt; struct file f; - char *c, *end; + if (!s.body) { + f.list = NULL; + f.elcnt = 0; + return f; + } end = s.body+s.len; c = s.body; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/vpatch.c new/wiggle-1.2/vpatch.c --- old/wiggle-1.1/vpatch.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/vpatch.c 2019-12-27 06:12:38.000000000 +0100 @@ -801,7 +801,7 @@ struct elmnt e; int found = 0; struct mp mp; - int o; + int o = 0; int len = strlen(search); do { @@ -1292,7 +1292,7 @@ } static int merge_window(struct plist *p, FILE *f, int reverse, int replace, - int selftest, int ignore_blanks, int just_diff) + int selftest, int ignore_blanks, int just_diff, int backup) { /* Display the merge window in one of the selectable modes, * starting with the 'merge' mode. @@ -1680,8 +1680,8 @@ attrset(A_NORMAL); } if (num >= 0) { - char buf[10]; - snprintf(buf, 10, "%d ", num); + char buf[12+1]; + snprintf(buf, sizeof(buf), "%d ", num); addstr(buf); } if (meta & META(0)) @@ -1790,8 +1790,8 @@ ci.merger, 0, &p->wiggles); p->chunks = p->conflicts; save_merge(fm, fb, fa, ci.merger, - p->outfile ?: p->file, - p->outfile ? 0 : !p->is_merge); + p->outfile ? p->outfile : p->file, + backup && (p->outfile ? 0 : !p->is_merge)); } if (!just_diff) free(sm.body); @@ -2347,7 +2347,7 @@ int is_merge, char *before, char *after, int replace, char *outfile, int selftest, int ignore_blanks, - int just_diff) + int just_diff, int backup) { struct plist p = {0}; @@ -2366,7 +2366,7 @@ freopen("/dev/null","w",stderr); return merge_window(&p, patch, reverse, replace, selftest, - ignore_blanks, just_diff); + ignore_blanks, just_diff, backup); } static void calc_one(struct plist *pl, FILE *f, int reverse, @@ -2427,7 +2427,7 @@ static int get_prev(int pos, struct plist *pl, int n, int mode) { int found = 0; - if (pos == -1) + if (pos == -1 || pl == NULL) return pos; do { if (pl[pos].prev == -1) @@ -2487,7 +2487,7 @@ static void draw_one(int row, struct plist *pl, FILE *f, int reverse, int ignore_blanks, int just_diff) { - char hdr[12]; + char hdr[2*12]; hdr[0] = 0; if (pl == NULL) { @@ -2538,7 +2538,7 @@ } static int save_one(FILE *f, struct plist *pl, int reverse, - int ignore_blanks) + int ignore_blanks, int backup) { struct stream sp, sa, sb, sm; struct file fa, fb, fm; @@ -2559,7 +2559,7 @@ csl2 = diff_patch(fb, fa); ci = make_merger(fm, fb, fa, csl1, csl2, 0, 1, 0); return save_merge(fm, fb, fa, ci.merger, - pl->file, 1); + pl->file, backup); } static char *main_help[] = { @@ -2613,8 +2613,8 @@ " Q = Don't quit just yet", NULL }; -static void main_window(struct plist *pl, int *np, FILE *f, int reverse, - int replace, int ignore_blanks, int just_diff) +static void main_window(struct plist *pl, int np, FILE *f, int reverse, + int replace, int ignore_blanks, int just_diff, int backup) { /* The main window lists all files together with summary information: * number of chunks, number of wiggles, number of conflicts. @@ -2669,7 +2669,6 @@ freopen("/dev/null","w",stderr); term_init(1); - pl = sort_patches(pl, np); while (1) { if (refresh == 2) { @@ -2694,7 +2693,7 @@ row = rows-1; tpos = pos; for (i = row; i > 1; i--) { - tpos = get_prev(tpos, pl, *np, mode); + tpos = get_prev(tpos, pl, np, mode); if (tpos == -1) { row = row - i + 1; break; @@ -2704,11 +2703,11 @@ tpos = pos; for (i = row; i >= 1; i--) { draw_one(i, &pl[tpos], f, reverse, ignore_blanks, just_diff); - tpos = get_prev(tpos, pl, *np, mode); + tpos = get_prev(tpos, pl, np, mode); } tpos = pos; for (i = row+1; i < rows; i++) { - tpos = get_next(tpos, pl, *np, mode, f, reverse,ignore_blanks, just_diff); + tpos = get_next(tpos, pl, np, mode, f, reverse,ignore_blanks, just_diff); if (tpos >= 0) draw_one(i, &pl[tpos], f, reverse, ignore_blanks, just_diff); else @@ -2742,7 +2741,7 @@ case 'N': case 'N'-64: case KEY_DOWN: - tpos = get_next(pos, pl, *np, mode, f, reverse, ignore_blanks, just_diff); + tpos = get_next(pos, pl, np, mode, f, reverse, ignore_blanks, just_diff); if (tpos >= 0) { pos = tpos; row++; @@ -2753,7 +2752,7 @@ case 'P': case 'P'-64: case KEY_UP: - tpos = get_prev(pos, pl, *np, mode); + tpos = get_prev(pos, pl, np, mode); if (tpos >= 0) { pos = tpos; row--; @@ -2764,13 +2763,13 @@ if (getmouse(&mevent) != OK) break; while (row < mevent.y && - (tpos = get_next(pos, pl, *np, mode, f, reverse, ignore_blanks, just_diff)) + (tpos = get_next(pos, pl, np, mode, f, reverse, ignore_blanks, just_diff)) >= 0) { pos = tpos; row++; } while (row > mevent.y && - (tpos = get_prev(pos, pl, *np, mode)) >= 0) { + (tpos = get_prev(pos, pl, np, mode)) >= 0) { pos = tpos; row--; } @@ -2790,9 +2789,11 @@ } else { int c; if (pl[pos].is_merge) - c = merge_window(&pl[pos], NULL, reverse, 0, 0, ignore_blanks, just_diff); + c = merge_window(&pl[pos], NULL, reverse, 0, 0, + ignore_blanks, just_diff, backup); else - c = merge_window(&pl[pos], f, reverse, 0, 0, ignore_blanks, just_diff); + c = merge_window(&pl[pos], f, reverse, 0, 0, + ignore_blanks, just_diff, backup); refresh = 2; if (c) { pl[pos].is_merge = 1; @@ -2822,7 +2823,7 @@ case 'q': cnt = 0; any = 0; - for (i = 0; i < *np; i++) + for (i = 0; i < np; i++) if (pl[i].end && !pl[i].is_merge) cnt++; else if (pl[i].end) @@ -2843,12 +2844,12 @@ if (ans < 0) break; if (ans) { - for (i = 0; i < *np; i++) { + for (i = 0; i < np; i++) { if (pl[i].end && !pl[i].is_merge) save_one(f, &pl[i], reverse, - ignore_blanks); + ignore_blanks, backup); } } else cnt = 0; @@ -2879,7 +2880,7 @@ /* Already saved */ mesg = "File is already saved."; } else { - if (save_one(f, &pl[pos], reverse, ignore_blanks) == 0) { + if (save_one(f, &pl[pos], reverse, ignore_blanks, backup) == 0) { pl[pos].is_merge = 1; snprintf(mesg_buf, cols, "Saved file %s.", @@ -2900,6 +2901,8 @@ mesg = "Cannot restore a folder."; else if (!pl[pos].is_merge) mesg = "File has not been saved, cannot restore."; + else if (!backup) + mesg = "Backups are disabled, nothing to restore!"; else { /* rename foo.porig to foo, and clear is_merge */ char *file = pl[pos].file; @@ -2919,7 +2922,7 @@ case 'I': /* Toggle ignoring blanks */ ignore_blanks = ignore_blanks ? 0 : IgnoreBlanks; refresh = 2; - for (i = 0; i < *np; i++) + for (i = 0; i < np; i++) pl[i].calced = 0; break; @@ -3014,7 +3017,7 @@ int vpatch(int argc, char *argv[], int patch, int strip, int reverse, int replace, char *outfilename, - int selftest, int ignore_blanks) + int selftest, int ignore_blanks, int backup) { /* NOTE argv[0] is first arg... * Behaviour depends on number of args and 'patch'. @@ -3071,7 +3074,9 @@ fprintf(stderr, "%s: aborting\n", Cmd); exit(2); } - main_window(pl, &num_patches, in, reverse, replace, ignore_blanks, just_diff); + pl = sort_patches(pl, &num_patches); + main_window(pl, num_patches, in, reverse, replace, ignore_blanks, + just_diff, backup); plist_free(pl, num_patches); fclose(in); break; @@ -3089,7 +3094,9 @@ fprintf(stderr, "%s: aborting\n", Cmd); exit(2); } - main_window(pl, &num_patches, f, reverse, replace,ignore_blanks, just_diff); + pl = sort_patches(pl, &num_patches); + main_window(pl, num_patches, f, reverse, replace, + ignore_blanks, just_diff, backup); plist_free(pl, num_patches); } else if (strlen(argv[0]) > 4 && strcmp(argv[0]+strlen(argv[0])-4, ".rej") == 0) { @@ -3097,34 +3104,34 @@ origname[strlen(origname) - 4] = '\0'; show_merge(origname, f, reverse, 0, NULL, NULL, replace, outfilename, - selftest, ignore_blanks, just_diff); + selftest, ignore_blanks, just_diff, backup); } else show_merge(argv[0], f, reverse, 1, NULL, NULL, replace, outfilename, - selftest, ignore_blanks, just_diff); + selftest, ignore_blanks, just_diff, backup); break; case 2: /* an orig and a diff/.rej or two files */ if (just_diff) { show_merge(NULL, NULL, reverse, 0, argv[0], argv[1], replace, outfilename, - selftest, ignore_blanks, just_diff); + selftest, ignore_blanks, just_diff, backup); break; } f = fopen(argv[1], "r"); - check_dir(argv[1], fileno(f)); if (!f) { fprintf(stderr, "%s: cannot open %s\n", Cmd, argv[0]); exit(1); } + check_dir(argv[1], fileno(f)); show_merge(argv[0], f, reverse, 0, NULL, NULL, replace, outfilename, - selftest, ignore_blanks, just_diff); + selftest, ignore_blanks, just_diff, backup); break; case 3: /* orig, before, after */ show_merge(argv[0], NULL, reverse, 0, argv[1], argv[2], replace, outfilename, - selftest, ignore_blanks, just_diff); + selftest, ignore_blanks, just_diff, backup); break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/wiggle.1 new/wiggle-1.2/wiggle.1 --- old/wiggle-1.1/wiggle.1 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/wiggle.1 2019-12-27 06:12:38.000000000 +0100 @@ -3,6 +3,7 @@ .\" .\" Copyright (C) 2003 Neil Brown <neilb@cse.unsw.edu.au> .\" Copyright (C) 2010-2013 Neil Brown <neilb@suse.de> +.\" Copyright (C) 2018-2019 Neil Brown <neil@brown.name> .\" .\" .\" This program is free software; you can redistribute it and/or modify @@ -19,9 +20,9 @@ .\" along with this program. .\" .\" Author: Neil Brown -.\" Email: <neilb@suse.de> +.\" Email: <neil@brown.name> .\" -.TH WIGGLE 1 "" v1.1 +.TH WIGGLE 1 "" v1.2 .SH NAME wiggle \- apply rejected patches and perform word-wise diffs .SH SYNOPSIS @@ -211,6 +212,12 @@ .I wiggle to always save the resulting merge when exiting. .TP +.B \-\-no-backup +Normally when an original file is replaced with the merged result, that +file is renamed to have a ".porig" extension, so that it is preserved. +If you don't want to keep the original, use this option to suppress +the backup. +.TP .BR \-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. @@ -358,13 +365,15 @@ .B \-r flag is given, the output is written to a file which replaces the original given file. In this case the original file -is renamed to have a +will normally be renamed to have a .B .porig suffix (for "patched original" which makes sense if you first use .I patch to apply a patch, and then use .I wiggle -to wiggle the rejects in). +to wiggle the rejects in). This can be suppressed with the +.B \-\-no\-backup +uption. .P Further if the .B -o diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/wiggle.c new/wiggle-1.2/wiggle.c --- old/wiggle-1.1/wiggle.c 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/wiggle.c 2019-12-27 06:12:38.000000000 +0100 @@ -543,6 +543,8 @@ fprintf(stderr, "%s: %s already exists\n", Cmd, orignew); + free(replacename); + free(orignew); return 2; } strcat(replacename, "XXXXXX"); @@ -552,6 +554,8 @@ "%s: could not create temporary file for %s\n", Cmd, replacename); + free(replacename); + free(orignew); return 2; } outfile = fdopen(fd, "w"); @@ -589,6 +593,24 @@ if (outfilename) fclose(outfile); else if (replace) { + struct stat statbuf; + + if (stat(argv[0], &statbuf) != 0) { + fprintf(stderr, + "%s: failed to stat original file. - %s\n", + Cmd, strerror(errno)); + free(replacename); + free(orignew); + return 2; + } + if (fchmod(fileno(outfile), statbuf.st_mode) != 0) { + fprintf(stderr, + "%s: failed to change permission of new file. - %s\n", + Cmd, strerror(errno)); + free(replacename); + free(orignew); + return 2; + } fclose(outfile); if (rename(argv[0], orignew) == 0 && rename(replacename, argv[0]) == 0) @@ -597,9 +619,13 @@ fprintf(stderr, "%s: failed to move new file into place.\n", Cmd); + free(replacename); + free(orignew); return 2; } } + free(replacename); + free(orignew); if (show_wiggles) return ci.conflicts + ci.wiggles > 0; else @@ -664,6 +690,7 @@ int mode = 0; int obj = 0; int replace = 0; + int backup = 1; int which = 0; int ispatch = 0; int reverse = 0; @@ -745,6 +772,9 @@ case 'r': replace = 1; continue; + case NO_BACKUP: + backup = 0; + continue; case 'o': outfile = optarg; replace = 1; @@ -802,7 +832,7 @@ if (mode == 'B') { vpatch(argc-optind, argv+optind, ispatch, strip, reverse, replace, outfile, selftest, - ignore_blanks); + ignore_blanks, backup); /* should not return */ exit(1); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/wiggle.h new/wiggle-1.2/wiggle.h --- old/wiggle-1.1/wiggle.h 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/wiggle.h 2019-12-27 06:12:38.000000000 +0100 @@ -191,7 +191,7 @@ extern int vpatch(int argc, char *argv[], int patch, int strip, int reverse, int replace, char *outfile, int selftest, - int ignore_blanks); + int ignore_blanks, int backup); extern char *Cmd; extern char Version[]; @@ -200,6 +200,7 @@ enum other_options { SELF_TEST = 300, REPORT_WIGGLES = 301, + NO_BACKUP, }; extern char Usage[]; extern char Help[]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wiggle-1.1/wiggle.spec new/wiggle-1.2/wiggle.spec --- old/wiggle-1.1/wiggle.spec 2017-09-28 14:37:04.000000000 +0200 +++ new/wiggle-1.2/wiggle.spec 2019-12-27 06:12:38.000000000 +0100 @@ -1,6 +1,6 @@ Summary: A tool for applying patches with conflicts Name: wiggle -Version: 1.1 +Version: 1.2 Release: 1 License: GPL Group: Development/Tools
participants (1)
-
root