summaryrefslogtreecommitdiff
path: root/tools/gst-indent
blob: e75338be0d03f5ad750d308eb39427e41c7d2f3e (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
#!/bin/sh

version=`gnuindent --version 2>/dev/null`
if test "x$version" = "x"; then
  version=`indent --version 2>/dev/null`
  if test "x$version" = "x"; then
    echo "GStreamer git pre-commit hook:"
    echo "Did not find GNU indent, please install it before continuing."
    exit 1
  fi
  INDENT=indent
else
  INDENT=gnuindent
fi

case `$INDENT --version` in
  GNU*)
      ;;
  default)
      echo "Did not find GNU indent, please install it before continuing."
      echo "(Found $INDENT, but it doesn't seem to be GNU indent)"
      exit 1
      ;;
esac

# Run twice. GNU indent isn't idempotent
# when run once
for i in 1 2; do
$INDENT \
  --braces-on-if-line \
  --case-brace-indentation0 \
  --case-indentation2 \
  --braces-after-struct-decl-line \
  --line-length80 \
  --no-tabs \
  --cuddle-else \
  --dont-line-up-parentheses \
  --continuation-indentation4 \
  --honour-newlines \
  --tab-size8 \
  --indent-level2 \
  --leave-preprocessor-space \
  $* || exit $?
done