<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56314>56314</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang-format modifies timestamps on certain files despite not modifying their content
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bneradt
      </td>
    </tr>
</table>

<pre>
    Apache Traffic Server uses clang-format to format its files. It generally works great, thank you for the tool. However we notice that after an initial configuration and build of the Traffic Server repository, the first run of clang-format modifies the timestamps on a couple files despite not changing their content. These files are header files included throughout the repo, so this results in basically the entire repository being rebuilt.

Interesting, subsequent runs of clang-format do not modify these files. Only the first run does.

This can be reproduced in a few minutes via docker like so:

```
# Pull the ATS docker image and create a running container from it.
docker pull ci.trafficserver.apache.org/ats/rockylinux:8
docker run -it  ci.trafficserver.apache.org/ats/rockylinux:8 /bin/bash

# From inside the docker container...
cd /var/tmp
git clone https://github.com/apache/trafficserver.git
cd trafficserver
autoreconf -fi
./configure
make -j8

# Wait for the build to complete, about 5-7 minutes.

# Run make again. Nothing should need to be rebuilt:
make -j8

make clang-format

# Verify no files got modified by clang-format.
git status

make -j8
# Many files are rebuilt. This is not expected.

# Re-run clang-format again, even removing the local repo installation.
rm -rf .git/fmt
make clang-format

make -j8
# No files are rebuilt.
```

Using find's `-mmin` argument shows that only a couple files got modified:

```
# Clone, autoreconf, make.
# Wait more than 5 minutes.

# Now, find all the files modified in the last 5 minutes in the repo:
find . -mmin -5
# Should show nothing.

# Now run the clang-format target, followed by the above find command:
make -j5 clang-format && echo -------------------- && find . -mmin -5
# ...
./plugins/certifier/certifier.cc
make[1]: Leaving directory '/home/bneradt/src/ts_asf_master_fix_clang_format_make_target'
--------------------
./.git
./.git/fmt
./.git/fmt/20200514
./.git/fmt/20200514/clang-format-20200514.tar.bz2
./.git/fmt/20200514/sha1
./include
./include/ink_autoconf.h.in
./include/ink_autoconf.h
```

The `.git/fmt` directory changes are simply the changes Traffic Server makes to install clang-format. That's not interesting. But the fact that clang-format is modifying `ink_autoconf.h.in` and `ink_autoconf.h` is interesting. That seems like a bug since the contents of those files are not being modified. Again, future invocations of clang-format do not result in those files being modified.

These are both autoconf generated files and are not checked in source code files, so Traffic Server can simply work around the issue by configuring our tools to avoid running clang-format on them. That avoids the issue for us, but I thought it might be helpful for me to record the observation here in case it's helpful to the project.

Here's the corresponding Apache Traffic Server issue:
https://github.com/apache/trafficserver/issues/8934

Thanks again for the project.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydV9tu4zYQ_Rr7hbBgy7fkwQ_ZXQQboN0W3bR9NCiKsrmRRJeknHW_vmeGkm3ZzqZtYCgSLzNnbofDzOaH1cNOqq0Wz04WhVHiq3Z77UTjtReqlPVmVFhXySCCFe2bCV4UptQ-EU9BbHStnSzLg3i17sWLjdMyDNKPImxl_SIOtqF9-NIQYctEfLavmlS8alHbYJSmlUHIImBQ1sLUJhhZCmXrwmwaJ4OxNSZykTWmzIUtWNgFYKd31ptg3SHq1oDofBCuqWlHz5TK5qYwMJBBmUr7IKudF6QGaptdqaOBItd-ZwIDFQr2bEy9oV3GEbyg65CI56323XrptNhqmQNQHDC1Kptc59jkbLPZ2iawVoJLQL3Fp_H49k0ZaL3IpDeKHUoLocI4fWaeyDSBcJq8EZLB-NNg_BCfT0AEQQHzLLvJvP6rgQTygr9yQ27ZLvYGK-vMSMQvdav-5MTcYuJc2zPhVghYxvCczRsFQw05sdCvojJ1E-CCvZHYrF7gk9K8aJg8mD6cCxosxu0vfqZT8WtTlqz_4flrt9lUcqM5DxSlGF4JV03OoFhIU5PXna2QoC3QdueOpCmThJgynjMmkZz4iXVw1qMMHk-H9YcSuL8D4l1PBrlgZIL4H3IERjJT01P6bc9ymPrIiGtvcs0Wt_qOJiVJa4zKSdBeOjxDtYuDG0BSpa2RdiHsPHk2f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