git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 4/4] doc add: renormalize is not idempotent for CRCRLF

From
Torsten Bögershausen <tboegi@web.de>
Date
Jul 10, 2022, 07:48 UTC
Message-ID
<20220710074848.ku2zobuck6vyim5d@tb-raspi4>
In-Reply-To
<d3b8ed97a105ea1d7e656c964b7eee378e11ede6.1657385781.git.gitgitgadget@gmail.com>
On Sat, Jul 09, 2022 at 04:56:21PM +0000, Philip Oakley via GitGitGadget wrote:
Show 8 quoted lines
> 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.

Show 18 quoted lines
>
> 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.
Previous: Philip OakleyNext: Philip Oakley
Message 13 of 45 in “Add some Glossary terms, and extra renormalize information.”
  1. 0/4 Add some Glossary terms, and extra renormalize information.Philip Oakley via GitGitGadget, Jul 9, 2022
  2. 1/4 glossary: add Object DataBase (ODB) abbreviationPhilip Oakley via GitGitGadget, Jul 9, 2022
  3. 2/4 glossary: add commit graph descriptionPhilip Oakley via GitGitGadget, Jul 9, 2022
  4. Junio C HamanoJul 9, 2022
  5. Philip OakleyJul 10, 2022
  6. Philip OakleyAug 30, 2022
  7. 3/4 glossary: add reachability bitmap descriptionPhilip Oakley via GitGitGadget, Jul 9, 2022
  8. 4/4 doc add: renormalize is not idempotent for CRCRLFPhilip Oakley via GitGitGadget, Jul 9, 2022
  9. Junio C HamanoJul 9, 2022
  10. Philip OakleyJul 10, 2022
  11. Junio C HamanoJul 10, 2022
  12. Philip OakleyJul 10, 2022
  13. Torsten BögershausenJul 10, 2022
  14. Philip OakleyJul 10, 2022
  15. Junio C HamanoAug 5, 2022
  16. Torsten BögershausenAug 6, 2022
  17. Philip OakleyAug 8, 2022
  18. Junio C HamanoAug 8, 2022
  19. Torsten BögershausenAug 9, 2022
  20. 0/1 .. Add extra renormalize information.Philip Oakley, Aug 10, 2022
  21. 1/1 doc add: renormalize is not idempotent for CRCRLFPhilip Oakley, Aug 10, 2022
  22. Torsten BögershausenAug 10, 2022
  23. Junio C HamanoAug 10, 2022
  24. Junio C HamanoJul 9, 2022
  25. Philip OakleyJul 10, 2022
  26. 0/3 Add some Glossary of terms informationPhilip Oakley, Oct 22, 2022
  27. 2/3 glossary: add "commit graph" descriptionPhilip Oakley, Oct 22, 2022
  28. Derrick StoleeOct 25, 2022
  29. Philip OakleyOct 29, 2022
  30. 3/3 glossary: add reachability bitmap descriptionPhilip Oakley, Oct 22, 2022
  31. Abhradeep ChakrabortyOct 24, 2022
  32. Junio C HamanoOct 24, 2022
  33. Philip OakleyOct 24, 2022
  34. Derrick StoleeOct 25, 2022
  35. Junio C HamanoOct 25, 2022
  36. Philip OakleyOct 29, 2022
  37. 1/3 doc: use 'object database' not ODB or abbreviationPhilip Oakley, Oct 22, 2022
  38. Junio C HamanoOct 23, 2022
  39. 0/4 Add some Glossary of terms informationPhilip Oakley, Oct 29, 2022
  40. 2/4 glossary: add "commit graph" descriptionPhilip Oakley, Oct 29, 2022
  41. 1/4 doc: use 'object database' not ODB or abbreviationPhilip Oakley, Oct 29, 2022
  42. 3/4 glossary: add reachability bitmap descriptionPhilip Oakley, Oct 29, 2022
  43. 4/4 doc: use "commit-graph" hyphenation consistentlyPhilip Oakley, Oct 29, 2022
  44. Taylor BlauOct 29, 2022
  45. Philip OakleyOct 29, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.