Skip to content

Commit

Permalink
astyle.sh: make it not touch unmodified files
Browse files Browse the repository at this point in the history
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 3f330aa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scripts/astyle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.