dotfiles

configuration files
git clone https://pi.duncano.de/git/dotfiles.git
Log | Files | Refs | README

commit eb3dd9df6f137d1ed508dcbd05cea07953d298c3
parent 9a155db09dbb9c1af98b400811e058a1e9267706
Author: Duncaen <mail@duncano.de>
Date:   Sat,  9 Jul 2016 21:31:54 +0200

diffed: update

Diffstat:
bin/diffed | 105+++++++++++++++++++++++++++++++++++++++++--------------------------------------
1 file changed, 54 insertions(+), 51 deletions(-)

diff --git a/bin/diffed b/bin/diffed @@ -1,16 +1,18 @@ #!/bin/sh # diffed [-CHT] [-pN] [-s SUBST -r REPL] [-x EXCLUDE] - filter for unified diffs # -# -C remove all non-diff lines -# -H remove diff headers -# -T remove file timestamps -# -p N strip N levels of directories from file names +# -C remove all non-diff lines +# -H remove diff headers +# -T remove file timestamps +# -p N strip N levels of directories from file names # -s SUBST -r REPL replace regexp SUBST with REPL in filenames -# -x EXCLUDE exclude diffs touching files matching regexp EXCLUDE +# -x EXCLUDE exclude diffs touching files matching regexp EXCLUDE # # To the extent possible under law, Christian Neukirchen has waived # all copyright and related or neighboring rights to this work. # http://creativecommons.org/publicdomain/zero/1.0/ +# +# 05may2016:: don't modify /dev/null path striptime=0 stripheader=0 @@ -24,61 +26,63 @@ nl=' while getopts CHTp:s:r:x: name do - case $name in - C) clean=1;; - H) stripheader=1;; - T) striptime=1;; - p) stripprefix=$((0+OPTARG));; - s) subst=$OPTARG;; - r) repl=$OPTARG;; - x) exclude="$exclude$nl$OPTARG";; - ?) printf "Usage: %s: [-CHT] [-pN] [-s SUBST -r REPL] [-x EXCLUDE]\n" $0 1>&2 - exit 1;; - esac + case $name in + C) clean=1;; + H) stripheader=1;; + T) striptime=1;; + p) stripprefix=$((0+OPTARG));; + s) subst=$OPTARG;; + r) repl=$OPTARG;; + x) exclude="$exclude$nl$OPTARG";; + ?) printf "Usage: %s: [-CHT] [-pN] [-s SUBST -r REPL] [-x EXCLUDE]\n" $0 1>&2 + exit 1;; + esac done exec awk -v "striptime=$striptime" \ - -v "stripheader=$stripheader" \ - -v "stripprefix=$stripprefix" \ - -v "subst=$subst" \ - -v "repl=$repl" \ - -v "excludes=$exclude" \ - -v "clean=$clean" ' + -v "stripheader=$stripheader" \ + -v "stripprefix=$stripprefix" \ + -v "subst=$subst" \ + -v "repl=$repl" \ + -v "excludes=$exclude" \ + -v "clean=$clean" ' BEGIN { - excludes = substr(excludes, 2) - split(excludes, exclude, "\n"); + excludes = substr(excludes, 2) + split(excludes, exclude, "\n"); } inpatch && /^[^ +-@]/ { inpatch = 0; strippatch = 0 } /^diff |^Index: / { if (!inheader) header = $0; inheader = 1; next } -/^---|\+\+\+/ { - inheader = 0 - inpatch = 1 - s = substr($0, 1, 4) - f = substr($0, 5) - if (i = index(f, "\t")) { - t = substr(f, i) - f = substr(f, 0, i-1) - } - if (striptime) - t = "" - for (i = 0; i < stripprefix; i++) - sub("[^/]*\\/", "", f) - if (subst && repl) - gsub(subst, repl, f) - $0 = s f t - for (e in exclude) - if (match(f, exclude[e])) - strippatch = 1 - if (!strippatch) { - if (header && !stripheader) - print(header) - print($0) - } - header = "" - next +/^--- |\+\+\+ / { + inheader = 0 + inpatch = 1 + s = substr($0, 1, 4) + f = substr($0, 5) + t = "" + if (i = index(f, "\t")) { + t = substr(f, i) + f = substr(f, 0, i-1) + } + if (striptime) + t = "" + if (f != "/dev/null") + for (i = 0; i < stripprefix; i++) + sub("[^/]*\\/", "", f) + if (subst && repl) + gsub(subst, repl, f) + $0 = s f t + for (e in exclude) + if (match(f, exclude[e])) + strippatch = 1 + if (!strippatch) { + if (header && !stripheader) + print header + print $0 + } + header = "" + next } inheader { header = header "\n" $0; next } @@ -87,4 +91,3 @@ inpatch { print; next } !clean { print } ' -