libtiff: Add .clang-format, .pre-commit-config.yaml and CONTRIBUTING.md

From 5e6a5fd6fac2007f553ea2753d39bf56875f3d09 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Thu, 8 Dec 2022 19:10:37 +0100
Subject: [PATCH] Add .clang-format, .pre-commit-config.yaml and
 CONTRIBUTING.md

---
 .clang-format           |  6 ++++++
 .pre-commit-config.yaml |  9 +++++++++
 CONTRIBUTING.md         | 19 +++++++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 .clang-format
 create mode 100644 .pre-commit-config.yaml
 create mode 100644 CONTRIBUTING.md

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..732fa91e
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,6 @@
+---
+BasedOnStyle: llvm
+IndentWidth: 4
+ColumnLimit: 80
+BreakBeforeBraces: Allman
+IndentCaseLabels: true
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..27aba544
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,9 @@
+repos:
+    -   repo: https://github.com/pre-commit/mirrors-clang-format
+        rev: 'v15.0.4'
+        hooks:
+        -   id: clang-format
+            exclude: >
+              (?x)^(
+                libtiff/tif_fax3sm.c
+              )
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..1291d61c
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,19 @@
+Contributing
+------------
+
+libtiff uses a ``.clang-format`` file to enforce code formatting rules.
+
+Automatic code reformatting can be done with pre-commit.
+
+Install (once) pre-commit with ``python -m pip install pre-commit``.
+
+Install it (once) in the libtiff git repository with ``pre-commit install``.
+
+Then the rules defined in the ``.pre-commit-config.yaml`` file will be
+enforced at ``git commit`` time, with automatic reformatting.
+
+Due to whole-tree code reformatting done during libtiff 4.5 development,
+``git blame`` information might be misleading. To avoid that, you need
+to modify your git configuration as following to ignore the revision of
+the whole-tree reformatting:
+``git config blame.ignoreRevsFile .git-blame-ignore-revs``.