Browse Source

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.
Idan Horowitz 3 years ago
parent
commit
9839a1699f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Userland/Utilities/gml-format.cpp

+ 2 - 0
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;