###############################################################################
# Set default behavior to automatically normalize line endings.
#
# This is a Windows-only project and several consumers REQUIRE CRLF in the
# working tree regardless of core.autocrlf:
#   - RegressionTests Resources\*.eml contain DKIM-signed messages whose body
#     hashes break if line endings change
#   - Raw-message tests send file/string content verbatim over SMTP; bare LFs
#     are rejected with "554 Message containing bare LF's"
# The database scripts are no longer among them: SQLScriptParser folds CRLF to
# LF and then splits a script into statements at a blank line (";" and a blank
# line for PostgreSQL), so a script parses with either ending.
# Hence: normalize text in the repo, but ALWAYS check out CRLF.
###############################################################################
* text=auto eol=crlf

###############################################################################
# The exception: everything a POSIX machine EXECUTES.
#
# The rule above is right for a Windows-only project and wrong for the moment
# one of its files is run by /bin/sh. A maintainer script checked out with CRLF
# fails as "bad interpreter: /bin/sh^M" when the package is installed, and the
# failure is at the user's machine rather than here. The systemd unit, the
# logrotate rule and the packaged configuration are read by parsers that are
# equally unforgiving, and the AppImage and PKGBUILD are shell.
#
# These are checked out LF on every platform, including Windows, where nothing
# reads them but an editor.
###############################################################################
hmailserver/source/Server/platform/packaging/** text eol=lf
build/*.sh text eol=lf
# The Linux CI jobs' scripts and their image's Dockerfile, which bash and
# docker build read on the project's own runner (.gitlab-ci.yml).
build/ci/*.sh text eol=lf
build/ci/*.Dockerfile text eol=lf
# The git hooks the repository ships (core.hooksPath build/hooks), which sh runs on
# every platform: a shebang ending in a carriage return names no interpreter.
build/hooks/* text eol=lf
# The package builds' scripts and the CMake toolchain file beside them
# (.gitlab/ci/packages-*.yml), which bash and CMake read on linix.
build/ci/packages/** text eol=lf
# The test lab on linix (build/lab/README.md): its scripts, which bash, node and
# python3 run there, and the compose file and the configuration files the
# containers read.
build/lab/** text eol=lf
# And the command-line client, which the .deb and the .rpm install as
# /usr/bin/hmctl: it opens with a shebang, so a CRLF checkout ships a file that
# fails as "bad interpreter: /usr/bin/env python3^M" on the user's machine and
# nowhere else.
hmailserver/source/Tools/Cli/hmctl text eol=lf
# And the source tarball's exclusion list (build/source-exclusions.txt), which the
# distributions' packaging reads with shell, rpm and Guix on Linux: a line read
# with its carriage return names a path that is not there, and nothing is left out.
build/source-exclusions.txt text eol=lf
# And Fedora Copr's make_srpm (.copr/Makefile, hmailserver/docs/Channels.md), which GNU
# make reads in Copr's Linux builder: a recipe line read with its carriage return
# runs a command whose last argument ends in one.
.copr/** text eol=lf
# And the Nix flake (hmailserver/docs/Nix.md): its shell snippets are Nix strings
# written into build scripts and into the NixOS machine's service, and a carriage
# return carried into one ends a command's last word with it; nix/probe.sh is bash.
flake.nix text eol=lf
flake.lock text eol=lf
nix/** text eol=lf
snap/** text eol=lf

###############################################################################
# The OpenPGP fixtures, byte for byte.
#
# These are keys, signatures and messages GnuPG 2.4 made, and two whole
# PGP/MIME messages whose signed part is signed over its exact octets. A
# signature does not survive a line ending being rewritten under it, and the
# rule at the top of this file would rewrite every one of them on checkout, so
# they are marked binary: no normalisation, no diff, the bytes GnuPG wrote.
###############################################################################
build/fixtures/openpgp/** binary

###############################################################################
# The PST fixtures: Outlook data files build/generate-pst-fixtures.py writes, whose
# every byte is covered by a CRC. Binary, as any .pst anywhere is.
###############################################################################
build/fixtures/pst/** binary
*.pst binary

###############################################################################
# The schema-upgrade gate's starting point (build/db-upgrade-gate.sh): the create
# scripts of schema 6029, byte for byte as commit 6eeb54bdf held them, CRLF and
# all, so that each is that commit's own blob and anyone can see it is:
#   git rev-parse 6eeb54bdf:hmailserver/source/DBScripts/CreateTablesMYSQL.sql
# names the same blob as HEAD:build/db-upgrade-6029/CreateTablesMySQL.sql.
###############################################################################
build/db-upgrade-6029/*.sql -text

# Explicitly binary
*.exe binary
*.dll binary
*.pfx binary
*.snk binary
*.ico binary
*.png binary
*.jpg binary
*.gif binary
*.bmp binary
*.msi binary
*.tlb binary
*.7z  binary
*.zip binary

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs     diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following 
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln       merge=binary
#*.csproj    merge=binary
#*.vbproj    merge=binary
#*.vcxproj   merge=binary
#*.vcproj    merge=binary
#*.dbproj    merge=binary
#*.fsproj    merge=binary
#*.lsproj    merge=binary
#*.wixproj   merge=binary
#*.modelproj merge=binary
#*.sqlproj   merge=binary
#*.wwaproj   merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg   binary
#*.png   binary
#*.gif   binary

###############################################################################
# diff behavior for common document formats
# 
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the 
# entries below.
###############################################################################
#*.doc   diff=astextplain
#*.DOC   diff=astextplain
#*.docx  diff=astextplain
#*.DOCX  diff=astextplain
#*.dot   diff=astextplain
#*.DOT   diff=astextplain
#*.pdf   diff=astextplain
#*.PDF   diff=astextplain
#*.rtf   diff=astextplain
#*.RTF   diff=astextplain
