2 ###########################################################################
4 # ---------------------
6 # Copyright : (C) 2008 by Juergen E. Fischer
7 # Email : jef at norbit dot de
8 ###########################################################################
10 # This program is free software; you can redistribute it and/or modify #
11 # it under the terms of the GNU General Public License as published by #
12 # the Free Software Foundation; either version 2 of the License, or #
13 # (at your option) any later version. #
15 ###########################################################################
17 TOPLEVEL=$(git rev-parse --show-toplevel)
19 PATH=$TOPLEVEL/scripts:$PATH
23 # GNU prefix command for mac os support (gsed, gsplit)
25 if [[ "$OSTYPE" =~ darwin* ]]; then
29 if ! type -p astyle.sh >/dev/null; then
30 echo astyle.sh not found
34 if ! type -p colordiff >/dev/null; then
41 if [ "$1" = "-c" ]; then
43 remove_temporary_files.sh
48 # determine changed files
49 MODIFIED=$(git status --porcelain| ${GP}sed -ne "s/^ *[MA] *//p" | sort -u)
50 #MODIFIED=$(find src -name "*.h")
52 if [ -z "$MODIFIED" ]; then
53 echo nothing was modified
57 # save original changes
58 REV=$(git log -n1 --pretty=%H)
59 git diff >sha-$REV.diff
61 ASTYLEDIFF=astyle.$REV.diff
66 N=$(echo $MODIFIED | wc -w)
67 for f in $MODIFIED; do
76 *.cpp|*.c|*.h|*.cxx|*.hxx|*.c++|*.h++|*.cc|*.hh|*.C|*.H|*.sip|*.py)
87 ASTYLEPROGRESS=" [$i/$N]" astyle.sh $f
88 if diff -u $m $f >>$ASTYLEDIFF; then
94 if [ -s "$ASTYLEDIFF" ]; then
96 # review astyle changes
97 colordiff <$ASTYLEDIFF | less -r
99 echo "Files changed (see $ASTYLEDIFF)"
107 # If there are whitespace errors, print the offending file names and fail.
108 exec git diff-index --check --cached HEAD --
112 # vim: set ts=8 noexpandtab :