blob: 20fff356797979b6f99471a322ac7df2f65ac4de (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/bin/bash
#
# Copyright, the authors of the Linux man-pages project
# SPDX-License-Identifier: GPL-3.0-or-later
set -Eefuo pipefail;
shopt -s lastpipe;
# 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 2; then
>&2 echo "$(basename "$0"): error: Too many arguments.";
exit 1;
fi;
git rev-parse --show-toplevel | read -r dir;
cd "$dir";
test -v MAN_KEEP_FORMATTING || export MAN_KEEP_FORMATTING=1;
test -v MANROFFOPT || export MANROFFOPT='-d AD=l';
# shellcheck disable=SC2206 # We want only non-empty variables in the array.
opts=($s $w $u);
case $# in
0) git diff --name-only; ;;
1) git diff --name-only "$1^..$1"; ;;
*) git diff --name-only "$1..$2"; ;;
esac \
| grep -E '(\.[[:digit:]]([[:alpha:]][[:alnum:]]*)?\>|\.man)+(\.man|\.in)*$' \
| sortman \
| while read -r f; do \
case $# in
0) old="HEAD:$f"; new="./$f"; ;;
1) old="$1^:$f"; new="$1:$f"; ;;
*) old="$1:$f"; new="$2:$f"; ;;
esac;
case $# in
0) cat "$new"; ;;
*) git show "$new"; ;;
esac \
| man /dev/stdin \
| diff -F'^[^ ]' --label "$old" --label "$new" "${opts[@]}" \
<(git show "$old" | man /dev/stdin) \
/dev/stdin \
|| true;
done;
|