Skip to content
Permalink
Browse files

astyle.sh: make it not touch unmodified files

Currently astyle.sh will rewrite files, even if no change are made.
This causes some editors (for example kate) to believe that the file
has been changed even if it is not the case. Letting the timestamp
untouched is not enough. So make 'flip' and 'unify_includes.pl'
operate on copies, and move the copies as the original file if
differences are found.
  • Loading branch information
rouault committed Feb 19, 2016
1 parent 30a738f commit 3f330aa6674dfe44d1e82e938ebf0e83c69dc6e1
Showing with 10 additions and 2 deletions.
  1. +10 −2 scripts/astyle.sh
@@ -56,7 +56,11 @@ set -e

astyleit() {
$ASTYLE --options="$ASTYLEOPTS" "$1"
scripts/unify_includes.pl "$1"
modified=$1.unify_includes_modified
cp "$1" "$modified"
scripts/unify_includes.pl "$modified"
diff "$f" "$modified" >/dev/null || mv "$modified" "$1"
rm -f "$modified"
}

for f in "$@"; do
@@ -103,6 +107,10 @@ for f in "$@"; do
echo "removed BOM from $f"
fi

flip -ub "$f"
modified=$f.flip_modified
cp "$f" "$modified"
flip -ub "$modified"
diff "$f" "$modified" >/dev/null || mv "$modified" "$f"
rm -f "$modified"
eval "$cmd '$f'"
done

0 comments on commit 3f330aa

Please sign in to comment.
You can’t perform that action at this time.