From 9839a1699fd538883f61e26e54803bc6281bc9fe Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Sat, 12 Feb 2022 19:28:22 +0200 Subject: [PATCH] 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. --- Userland/Utilities/gml-format.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Utilities/gml-format.cpp b/Userland/Utilities/gml-format.cpp index cd0d4412430..84d014bff84 100644 --- a/Userland/Utilities/gml-format.cpp +++ b/Userland/Utilities/gml-format.cpp @@ -30,6 +30,8 @@ ErrorOr 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;