Skip to content

Commit 3f330aa

Browse files
committed
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.
1 parent 30a738f commit 3f330aa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/astyle.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ set -e
5656

5757
astyleit() {
5858
$ASTYLE --options="$ASTYLEOPTS" "$1"
59-
scripts/unify_includes.pl "$1"
59+
modified=$1.unify_includes_modified
60+
cp "$1" "$modified"
61+
scripts/unify_includes.pl "$modified"
62+
diff "$f" "$modified" >/dev/null || mv "$modified" "$1"
63+
rm -f "$modified"
6064
}
6165

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

106-
flip -ub "$f"
110+
modified=$f.flip_modified
111+
cp "$f" "$modified"
112+
flip -ub "$modified"
113+
diff "$f" "$modified" >/dev/null || mv "$modified" "$f"
114+
rm -f "$modified"
107115
eval "$cmd '$f'"
108116
done

0 commit comments

Comments
 (0)