git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Andreas Heiduk <asheiduk@gmail.com>
To: git@vger.kernel.org
Cc: asheiduk@gmail.com, tboegi@web.de, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v4] doc: do not use `rm .git/index` when normalizing line endings
Date: Wed, 14 Jun 2017 08:51:39 +0200	[thread overview]
Message-ID: <20170614065139.10825-1-asheiduk@gmail.com> (raw)
In-Reply-To: <20170613221506.32732-1-asheiduk@gmail.com>

When illustrating how to normalize the line endings, the
documentation in gitattributes tells the user to `rm .git/index`.

This is incorrect for two reasons:

 - Users shouldn't be instructed to mess around with the internal
   implementation of Git using raw file system tools like `rm`.

 - Within a submodule or an additional working tree `.git` is just a
   file containing a `gitdir: <path>` pointer into the real `.git`
   directory.  Therefore `rm .git/index` does not work.

The purpose of the `rm .git/index` instruction is to remove all entries
from the index without touching the working tree.  The way to do this
with Git is to use `read-tree --empty`.

Signed-off-by: Andreas Heiduk <asheiduk@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Torsten Bögershausen <tboegi@web.de>
---
 Documentation/gitattributes.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 473648386..2a2d7e2a4 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -229,7 +229,7 @@ From a clean working directory:
 
 -------------------------------------------------
 $ echo "* text=auto" >.gitattributes
-$ rm .git/index     # Remove the index to re-scan the working directory
+$ git read-tree --empty   # Clean index, force re-scan of working directory
 $ git add .
 $ git status        # Show files that will be normalized
 $ git commit -m "Introduce end-of-line normalization"
-- 
2.13.0


      parent reply	other threads:[~2017-06-14  6:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-10  9:07 [PATCH] doc: fix location of index in worktree scenatio Andreas Heiduk
2017-06-10 11:17 ` Junio C Hamano
2017-06-10 17:24   ` Andreas Heiduk
2017-06-10 17:38 ` [PATCH v2] " Andreas Heiduk
2017-06-12 10:03   ` Torsten Bögershausen
2017-06-12 10:48     ` Andreas Heiduk
2017-06-12 16:06     ` Junio C Hamano
2017-06-13  4:29       ` Torsten Bögershausen
2017-06-13 13:07         ` Junio C Hamano
2017-06-13 22:15 ` [PATCH v3] doc: do not use `rm .git/index` when normalizing line endings Andreas Heiduk
2017-06-14  4:06   ` Torsten Bögershausen
2017-06-14  6:51   ` Andreas Heiduk [this message]

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=20170614065139.10825-1-asheiduk@gmail.com \
    --to=asheiduk@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tboegi@web.de \
    /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).