From 4c7d80edcbbcf6948ca61fa0acd150da00d4472e Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 6 Jan 2023 12:42:16 +0100 Subject: [PATCH] bin: improve file diffing --- .local/bin/scripts/dif | 2 +- .local/bin/scripts/treediff | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 .local/bin/scripts/treediff diff --git a/.local/bin/scripts/dif b/.local/bin/scripts/dif index 1cad345..62deac9 100755 --- a/.local/bin/scripts/dif +++ b/.local/bin/scripts/dif @@ -16,7 +16,7 @@ if ! test "$command"; then (*sqlite*) sqldiff --summary "${files[@]}" | grep -v '0 changes, 0 inserts, 0 deletes';; # TODO syntax highlighting for INSERT/UPDATE/DELETE (text/*) # Use wiked-diff only for text <10MB - if test 10000000 -gt "$(stat --format=%s *.geojson | paste -s -d'+' | bc)" + if test 10000000 -gt "$(stat --format=%s "${files[@]}" | paste -s -d'+' | bc)" then wiked-diff "${files[@]}" else diff --color=always --unified=1 --report-identical-files "${files[@]}" fi;; diff --git a/.local/bin/scripts/treediff b/.local/bin/scripts/treediff new file mode 100755 index 0000000..8974803 --- /dev/null +++ b/.local/bin/scripts/treediff @@ -0,0 +1,7 @@ +#!/bin/sh -e +# Diff the existing filenames between the given directories +command() { + find "$1" -printf '%P\n' | sort +} +wiked-diff --colored-blocks false <(command "$1") <(command "$2") | + less --RAW-CONTROL-CHARS --quit-on-intr --quit-if-one-screen