git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: <git@vger.kernel.org>
Cc: Jeff King <peff@peff.net>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Derrick Stolee <dstolee@microsoft.com>
Subject: [PATCH 3/4] gitfaq: give advice on using eol attribute in gitattributes
Date: Wed, 20 Oct 2021 01:06:22 +0000	[thread overview]
Message-ID: <20211020010624.675562-4-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20211020010624.675562-1-sandals@crustytoothpaste.net>

In the FAQ, we tell people how to use the text attribute, but we fail to
explain what to do with the eol attribute.  As we ourselves have
noticed, most shell implementations do not care for carriage returns,
and as such, people will practically always want them to use LF endings.
Similar things can be said for batch files on Windows, except with CRLF
endings.

Since these are common things to have in a repository, let's help users
make a good decision by recommending that they use the gitattributes
file to correctly check out the endings.

In addition, let's correct the cross-reference to this question, which
originally referred to "the following entry", even though a new entry
has been inserted in between.  The cross-reference notation should
prevent this from occurring and provide a link in formats, such as HTML,
which support that.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 Documentation/gitfaq.txt | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/Documentation/gitfaq.txt b/Documentation/gitfaq.txt
index abc0f62e6c..85ac99c7b2 100644
--- a/Documentation/gitfaq.txt
+++ b/Documentation/gitfaq.txt
@@ -401,8 +401,9 @@ I'm on Windows and git diff shows my files as having a `^M` at the end.::
 +
 You can store the files in the repository with Unix line endings and convert
 them automatically to your platform's line endings.  To do that, set the
-configuration option `core.eol` to `native` and see the following entry for
-information about how to configure files as text or binary.
+configuration option `core.eol` to `native` and see
+<<recommended-storage-settings,the question on recommended storage settings>>
+for information about how to configure files as text or binary.
 +
 You can also control this behavior with the `core.whitespace` setting if you
 don't wish to remove the carriage returns from your line endings.
@@ -464,14 +465,25 @@ references, URLs, and hashes stored in the repository.
 +
 We also recommend setting a linkgit:gitattributes[5] file to explicitly mark
 which files are text and which are binary.  If you want Git to guess, you can
-set the attribute `text=auto`.  For example, the following might be appropriate
-in some projects:
+set the attribute `text=auto`.
++
+With text files, Git will generally the repository contains LF endings in the
+repository, and will honor `core.autocrlf` and `core.eol` to decide what options
+to use when checking files out.  You can also override this by specifying a
+particular line ending such as `eol=lf` or `eol=crlf` if those files must always
+have that ending (e.g., for functionality reasons).
++
+For example, the following might be appropriate in some projects:
 +
 ----
 # By default, guess.
 *	text=auto
 # Mark all C files as text.
 *.c	text
+# Ensure all shell files end up with LF endings and all batch files end up
+# with CRLF endings in the working tree and both end up with LF in the repo.
+*.sh text eol=lf
+*.bat text eol=crlf
 # Mark all JPEG files as binary.
 *.jpg	binary
 ----

  parent reply	other threads:[~2021-10-20  1:06 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-20  1:06 [PATCH 0/4] Additional FAQ entries brian m. carlson
2021-10-20  1:06 ` [PATCH 1/4] gitfaq: add advice on monorepos brian m. carlson
2021-10-20  4:45   ` Bagas Sanjaya
2021-10-20 10:54   ` Ævar Arnfjörð Bjarmason
2021-10-20 21:19     ` brian m. carlson
2021-10-20 11:55   ` Johannes Schindelin
2021-10-20 14:11   ` Philip Oakley
2021-10-20 22:22     ` brian m. carlson
2021-10-25 10:44       ` Philip Oakley
2021-10-20  1:06 ` [PATCH 2/4] gitfaq: add documentation on proxies brian m. carlson
2021-10-20 11:57   ` Johannes Schindelin
2021-10-20 22:17     ` brian m. carlson
2021-10-20 14:48   ` Junio C Hamano
2021-10-20 22:19     ` brian m. carlson
2021-10-20  1:06 ` brian m. carlson [this message]
2021-10-20  1:21   ` [PATCH 3/4] gitfaq: give advice on using eol attribute in gitattributes Eric Sunshine
2021-10-20  1:27     ` brian m. carlson
2021-10-20 12:02       ` Johannes Schindelin
2021-10-20 22:25         ` brian m. carlson
2021-10-21 12:02           ` Johannes Schindelin
2021-10-20  1:06 ` [PATCH 4/4] doc: add a FAQ entry about syncing working trees brian m. carlson
2021-10-20  4:58   ` Bagas Sanjaya
2021-10-20 14:05     ` Philip Oakley
2021-10-20 23:35   ` Ævar Arnfjörð Bjarmason
2021-10-21  0:03     ` brian m. carlson
2021-10-21  0:33       ` Ævar Arnfjörð Bjarmason
2021-10-20  1:06 ` [PATCH 4/4] gitfaq: add " brian m. carlson
2021-10-20  1:38   ` Eric Sunshine
2021-10-20 21:36     ` brian m. carlson
2021-10-20 12:09   ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211020010624.675562-4-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).