]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
src/bin/duffman: Diff against HEAD, not the system pages
authorAlejandro Colomar <alx@kernel.org>
Thu, 9 Jan 2025 12:24:13 +0000 (13:24 +0100)
committerAlejandro Colomar <alx@kernel.org>
Sat, 11 Jan 2025 18:53:16 +0000 (19:53 +0100)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
src/bin/duffman

index 4c05b73f21185042531415c9ebb33304d3c50654..48cd6d2348c5be4186e271a76bc94bdb448da3aa 100755 (executable)
@@ -4,17 +4,48 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 
 set -Eeuo pipefail;
+shopt -s lastpipe;
 
-# diff all modified pages against the system ones.
+# Defaults:
+s='';
+u='-u';
+w='';
+
+while getopts "sU:w" opt; do
+       case "$opt" in
+       s)      s='-s';         ;;
+       U)      u="-U$OPTARG";  ;;
+       w)      w='-w';         ;;
+       \?)     exit 1;         ;;
+       *)      exit 1;         ;;
+       esac;
+done;
+shift $((OPTIND-1));
+
+if test $# -gt 0; then
+       >&2 echo "$(basename "$0"): error: Too many arguments.";
+       exit 1;
+fi;
 
 cd $(git rev-parse --show-toplevel);
 
+test -v MAN_KEEP_FORMATTING || export MAN_KEEP_FORMATTING=1;
+
+# shellcheck disable=SC2206  # We want only non-empty variables in the array.
+opts=($s $w $u);
+
 git diff --name-only \
 | grep -E '(\.[[:digit:]]([[:alpha:]][[:alnum:]]*)?\>|\.man)+(\.man|\.in)*$' \
 | sortman \
 | while read f; do \
-       sys="$(basename "$f")";
+       old="HEAD:$f";
+       new="./$f";
 
-       diffman "$@" "$sys" "$f" || true;
+       cat "$new" \
+       | man /dev/stdin \
+       | diff --label "$old" --label "$new" "${opts[@]}" \
+               <(git show "$old" | man /dev/stdin) \
+               /dev/stdin \
+       || true;
 done \
 | less -R;