File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed
Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ if ! [ -x astyle.sh ]; then
4+ PATH=$PATH :$( dirname $0 )
5+ fi
6+
7+ set -e
8+
9+ # determine changed files
10+ MODIFIED=$( svn status | sed -ne " s/^[MA] *//p" )
11+
12+ if [ -z " $MODIFIED " ]; then
13+ echo nothing was modified
14+ exit 1
15+ fi
16+
17+ # save original changes
18+ REV=$( svn info | sed -ne " s/Revision: //p" )
19+ svn diff > r$REV .diff
20+
21+ ASTYLEDIFF=astyle.r$REV .diff
22+ > $ASTYLEDIFF
23+
24+ # reformat
25+ for f in $MODIFIED ; do
26+ case " $f " in
27+ * .cpp|* .h|* .c|* .h|* .cxx|* .hxx|* .c++|* .h++|* .cc|* .hh|* .C|* .H)
28+ ;;
29+
30+ * )
31+ continue
32+ ;;
33+ esac
34+
35+ m=$f .r$REV .prepare
36+
37+ cp $f $m
38+ astyle.sh $f
39+ if diff -u $m $f >> $ASTYLEDIFF ; then
40+ # no difference found
41+ rm $m
42+ fi
43+ done
44+
45+ if [ -s " $ASTYLEDIFF " ]; then
46+ if tty -s; then
47+ # review astyle changes
48+ colordiff < $ASTYLEDIFF | less -r
49+ else
50+ echo " Files changed (see $ASTYLEDIFF )"
51+ fi
52+ else
53+ rm $ASTYLEDIFF
54+ fi
You can’t perform that action at this time.
0 commit comments