forked from gnutls/gnutls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
indent-gnutls
executable file
·49 lines (41 loc) · 1.03 KB
/
indent-gnutls
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
#!/bin/sh
# Copyright (c) 2022 Simon Josefsson
# Copyright (c) 2023 Daiki Ueno
# License: GPLv3+ <http://gnu.org/licenses/gpl.html>
: ${CLANG_FORMAT=clang-format}
if ! $CLANG_FORMAT --version 2>&1 >/dev/null; then
echo 1>&2 "$0: clang-format is missing"
exit 77
fi
parallel=0
mode=indent
while test $# -gt 0; do
case "$1" in
--parallel | -p )
shift
parallel=$1
shift ;;
--check )
mode=check
shift ;;
--help )
echo "Usage: indent-gnutls [--parallel=MAX-PROCS] [--check]"
exit ;;
-* )
echo "indent-gnutls: unknown option $1" 1>&2
echo "Try 'indent-gnutls --help' for more information." 1>&2
exit 1 ;;
* )
break ;;
esac
done
case $mode in
check )
CLANG_FORMAT_ARGS="$CLANG_FORMAT_ARGS --dry-run -Werror"
;;
indent )
CLANG_FORMAT_ARGS="$CLANG_FORMAT_ARGS -i"
;;
esac
git ls-files -z | grep -z '\.[ch]\(.in\)\?$' | grep -z -v '^./devel/' | xargs -P "$parallel" -0 -n1 "$CLANG_FORMAT" $CLANG_FORMAT_ARGS
exit $?