git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Philip Oakley via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Philip Oakley <philipoakley@iee.email>
Subject: Re: [PATCH 4/4] doc add: renormalize is not idempotent for CRCRLF
Date: Sun, 10 Jul 2022 09:48:48 +0200	[thread overview]
Message-ID: <20220710074848.ku2zobuck6vyim5d@tb-raspi4> (raw)
In-Reply-To: <d3b8ed97a105ea1d7e656c964b7eee378e11ede6.1657385781.git.gitgitgadget@gmail.com>

On Sat, Jul 09, 2022 at 04:56:21PM +0000, Philip Oakley via GitGitGadget wrote:
> From: Philip Oakley <philipoakley@iee.email>
>
> Bug report
>  https://lore.kernel.org/git/AM0PR02MB56357CC96B702244F3271014E8DC9@AM0PR02MB5635.eurprd02.prod.outlook.com/
> noted that a file containing /r/r/n needed renormalising twice.
>
> This is by design. Lone CR characters, not paired with an LF, are left
> unchanged.

This is all fine.

> Note the lack of idempotentness of the "clean" filter in the
> documentation.

The clean filter is idempotent, I would claim, see below.
You can run it, and re-run, and re-run, there will no other changes.
CRLF in the worktree will become LF in the repo,
'lone CR' stay as they are.
In that sense, CRCRLF in the worktree will become CRLF in the repo.
You can the renormalize again and again.

The "trick" is that the user has to decide what CRCRLF mean and what
should happen in the repo:
CRCRLF in the worktree becomes one line ending (one LF in the repo)
or
CRCRLF in the worktree becomes two line endings ( LFLF in the repo)

For a) you can use dos2unix twice.
Or run `git add --renormalize` followed by
`rm git.bdf`
`git restore .`

The thing is that we used a combination of different commands
$ git add --renormalize .
$ git commit -m "Renormalize bdf.txt"
$ rm git.bdf
$ git restore .
$ git add --renormalize .
$ git commit -m "Renormalize a second time bdf.txt"

... to clean up this very situation.

And, if CRCRLF should have become LFLF instead ?
Probably a python script is needed to fix this.
(or some other script/program in the language of your choice)

We could argue that
`git add --renormalize` is idempotent, but a series of carefully crafted
commands is not.
In short, what is missing is the documentation how CRCRLF is handled by
Git.

>
> Renormalize was introduced at 9472935d81e (add: introduce "--renormalize",
> Torsten Bögershausen, 2017-11-16)
>
> Signed-off-by: Philip Oakley <philipoakley@iee.email>
> ---
>  Documentation/git-add.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/git-add.txt b/Documentation/git-add.txt
> index 11eb70f16c7..c4a5ad11a6b 100644
> --- a/Documentation/git-add.txt
> +++ b/Documentation/git-add.txt
> @@ -188,7 +188,8 @@ for "git add --no-all <pathspec>...", i.e. ignored removed files.
>  	forcibly add them again to the index.  This is useful after
>  	changing `core.autocrlf` configuration or the `text` attribute
>  	in order to correct files added with wrong CRLF/LF line endings.
> -	This option implies `-u`.

> +	This option implies `-u`. Lone CR characters are untouched, so
> +	cleaning not idempotent. A CRCRLF sequence cleans to CRLF.

How about this:

This option implies `-u`. Lone CR characters are untouched. CRCRLF cleans to CRLF.


  parent reply	other threads:[~2022-07-10  8:12 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09 16:56 [PATCH 0/4] Add some Glossary terms, and extra renormalize information Philip Oakley via GitGitGadget
2022-07-09 16:56 ` [PATCH 1/4] glossary: add Object DataBase (ODB) abbreviation Philip Oakley via GitGitGadget
2022-07-09 16:56 ` [PATCH 2/4] glossary: add commit graph description Philip Oakley via GitGitGadget
2022-07-09 21:20   ` Junio C Hamano
2022-07-10 21:37     ` Philip Oakley
2022-08-30 14:33       ` Philip Oakley
2022-07-09 16:56 ` [PATCH 3/4] glossary: add reachability bitmap description Philip Oakley via GitGitGadget
2022-07-09 16:56 ` [PATCH 4/4] doc add: renormalize is not idempotent for CRCRLF Philip Oakley via GitGitGadget
2022-07-09 21:06   ` Junio C Hamano
2022-07-10 21:52     ` Philip Oakley
2022-07-10 22:04       ` Junio C Hamano
2022-07-10 22:25         ` Philip Oakley
2022-07-10  7:48   ` Torsten Bögershausen [this message]
2022-07-10 22:09     ` Philip Oakley
2022-08-05 22:26       ` Junio C Hamano
2022-08-06 19:22         ` Torsten Bögershausen
2022-08-08 14:32         ` Philip Oakley
2022-08-08 16:21           ` Junio C Hamano
2022-08-09 18:44           ` Torsten Bögershausen
2022-08-10 14:44         ` [PATCH v2 0/1] .. Add extra renormalize information Philip Oakley
2022-08-10 14:44           ` [PATCH v2 1/1] doc add: renormalize is not idempotent for CRCRLF Philip Oakley
2022-08-10 17:11             ` Torsten Bögershausen
2022-08-10 17:42             ` Junio C Hamano
2022-07-09 21:34 ` [PATCH 0/4] Add some Glossary terms, and extra renormalize information Junio C Hamano
2022-07-10 15:20   ` Philip Oakley
2022-10-22 22:25 ` [PATCH v2 0/3] Add some Glossary of terms information Philip Oakley
2022-10-22 22:25   ` [PATCH v2 1/3] doc: use 'object database' not ODB or abbreviation Philip Oakley
2022-10-22 22:25   ` [PATCH v2 2/3] glossary: add "commit graph" description Philip Oakley
2022-10-25 12:31     ` Derrick Stolee
2022-10-29 16:32       ` Philip Oakley
2022-10-22 22:25   ` [PATCH v2 3/3] glossary: add reachability bitmap description Philip Oakley
2022-10-24  7:43     ` Abhradeep Chakraborty
2022-10-24 16:39       ` Junio C Hamano
2022-10-24 21:23         ` Philip Oakley
2022-10-25 12:34           ` Derrick Stolee
2022-10-25 15:53             ` Junio C Hamano
2022-10-29 16:36             ` Philip Oakley
2022-10-23  1:49   ` [PATCH v2 0/3] Add some Glossary of terms information Junio C Hamano
2022-10-29 16:41   ` [PATCH v3 0/4] " Philip Oakley
2022-10-29 16:41     ` [PATCH v3 1/4] doc: use 'object database' not ODB or abbreviation Philip Oakley
2022-10-29 16:41     ` [PATCH v3 2/4] glossary: add "commit graph" description Philip Oakley
2022-10-29 16:41     ` [PATCH v3 3/4] glossary: add reachability bitmap description Philip Oakley
2022-10-29 16:41     ` [PATCH v3 4/4] doc: use "commit-graph" hyphenation consistently Philip Oakley
2022-10-29 17:24     ` [PATCH v3 0/4] Add some Glossary of terms information Taylor Blau
2022-10-29 17:34       ` Philip Oakley

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

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

  git send-email \
    --in-reply-to=20220710074848.ku2zobuck6vyim5d@tb-raspi4 \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=philipoakley@iee.email \
    /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.
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 NNTP newsgroup(s).