summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-02-12 19:28:22 +0200
committerIdan Horowitz <idan.horowitz@gmail.com>2022-02-13 02:36:35 +0200
commit9839a1699fd538883f61e26e54803bc6281bc9fe (patch)
tree6a70392e1ef73441a52979dfc402e7b4439ec7cb
parent0a93bf5e7b9519ba2402ef0ccf37dbf389665098 (diff)
downloadserenity-9839a1699fd538883f61e26e54803bc6281bc9fe.zip
gml-format: Skip writing formatted GML to file if no changes were made
This stops all GML files from appeared under the "Changes not staged for commit" section of the commit message comment due to the changed last-modified timestamp of the file.
-rw-r--r--Userland/Utilities/gml-format.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp
index cd0d441243..84d014bff8 100644
--- a/Userland/Utilities/gml-format.cpp
+++ b/Userland/Utilities/gml-format.cpp
@@ -30,6 +30,8 @@ ErrorOr<bool> format_file(StringView path, bool inplace)
}
auto formatted_gml = formatted_gml_or_error.release_value();
if (inplace && !read_from_stdin) {
+ if (formatted_gml == contents)
+ return true;
if (!file->seek(0) || !file->truncate(0)) {
warnln("Could not truncate {}: {}", path, file->error_string());
return false;