summaryrefslogtreecommitdiff
path: root/git-clang-format.sh
diff options
context:
space:
mode:
Diffstat (limited to 'git-clang-format.sh')
-rwxr-xr-xgit-clang-format.sh9
1 files changed, 8 insertions, 1 deletions
diff --git a/git-clang-format.sh b/git-clang-format.sh
index d374b66bd..6348652c1 100755
--- a/git-clang-format.sh
+++ b/git-clang-format.sh
@@ -1,3 +1,10 @@
#!/bin/sh
cd "$(dirname "$0")"
-git clang-format-3.8 --diff "$@" | sed "s#+/\*\}\}\}\*/#+ /*}}}*/#" | patch -p1
+CLANG_FORMAT="$(find $(echo "$PATH" | tr ':' ' ') -name 'git-clang-format-*' | sort | tail -n1 )"
+if [ -z "$CLANG_FORMAT" ]; then
+ echo >&2 'Could not find a clang-format to use. Is the package clang-format installed?'
+ exit 1
+fi
+git "$(basename "$CLANG_FORMAT" | cut -d'-' -f 2-)" --diff "$@" | \
+ sed "s#+/\*\}\}\}\*/#+ /*}}}*/#" | \
+ patch -p1