• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Runs clang-format on the files changed between HEAD and $1, which defaults to
4# origin/master.
5
6# to pick up git-clang-format from scripts/
7export PATH=$(dirname $0):$PATH
8
9CLANG_FORMAT=${CLANG_FORMAT:-clang-format}
10GITREF=${1:-origin/master}
11
12if ! hash $CLANG_FORMAT 2> /dev/null; then
13  echo "Could not find clang-format tool" 1>&2
14  exit 1
15fi
16
17cmd="git clang-format $GITREF --binary $CLANG_FORMAT --diff --extensions h,c,cc"
18
19n=$($cmd --quiet | wc -l)
20if [ $n -gt 0 ]; then
21  $cmd -v
22  exit 1
23fi
24