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

Re: [PATCH v1 1/1] git diff --quiet exits with 1 on clean tree with CRLF conversions

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 4, 2017, 19:59 UTC
Message-ID
<xmqq4lz87r01.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<9c9eeb35-e1c1-ec46-1d85-ef6a05886880@web.de>
Torsten Bögershausen <tboegi@web.de> writes:
Show 14 quoted lines
>>>         enum safe_crlf crlf_warn = (safe_crlf == SAFE_CRLF_FAIL
>>>                                     ? SAFE_CRLF_WARN
>>>                                     : safe_crlf);
>>> +       if (size_only)
>>> +               crlf_warn = SAFE_CRLF_FALSE;
>> 
>> If you were to go this route, it may be sufficient to change its
>> initialization from WARN to FALSE _unconditionally_, because this
>> function uses the convert_to_git() only to _show_ the differences by
>> computing canonical form out of working tree contents, and the
>> conversion is not done to _write_ into object database to create a
>> new object.
>
> Hm, since when (is it not used) ?

Since forever, but my statement above said "this function", which may have confused you, where it could have said diff_populate_filespec().

Surely it is possible for somebody to diff_populate_filespec(s, 0) and then call hash_sha1_file(s->data, s->size, "blob", ...) to write the data into the object database to create a new object. But that sounds really crazy, no?

Show 6 quoted lines
> The SAFE_CRLF_FAIL was converted into WARN here:
> commit 5430bb283b478991a979437a79e10dcbb6f20e28
> Author: Junio C Hamano <gitster@pobox.com>
> Date:   Mon Jun 24 14:35:04 2013 -0700
>
>     diff: demote core.safecrlf=true to core.safecrlf=warn
Yes.
> Does this all means that, looking back,  5430bb283b478991 could have been more
> aggressive and could have used SAFE_CRLF_FALSE ?

That is pretty much the statement, to which you said "since when", suspects.

> And we can do this change now?

I am not sure. The conversion the safe-crlf code does is unsafe and it is a disservice to users not to warn whenever we notice they are risking information loss. Maybe time they run "git diff" is not a good time to warn, as they may not be actually adding the file as-is, but if warning against information loss at "git diff" time is important enough, the I think that should not be squelched by the "--quiet" option, which is about "do not show the patch text output". It should not be taken as "do not diagnose any errors".

Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 23 of 29 in “git diff --quiet exits with 1 on clean tree with CRLF conversions”
  1. Mike CroweFeb 17, 2017
  2. Junio C HamanoFeb 17, 2017
  3. Mike CroweFeb 17, 2017
  4. Mike CroweFeb 20, 2017
  5. Junio C HamanoFeb 20, 2017
  6. Mike CroweFeb 25, 2017
  7. Junio C HamanoFeb 27, 2017
  8. Torsten BögershausenFeb 28, 2017
  9. Junio C HamanoFeb 28, 2017
  10. 1/1 git diff --quiet exits with 1 on clean tree with CRLF conversionstboegi@web.de, Mar 1, 2017
  11. Junio C HamanoMar 1, 2017
  12. Junio C HamanoMar 1, 2017
  13. Jeff KingMar 2, 2017
  14. Junio C HamanoMar 2, 2017
  15. Jeff KingMar 2, 2017
  16. diff: do not short-cut CHECK_SIZE_ONLY check in diff_populate_filespec()Junio C Hamano, Mar 2, 2017
  17. Mike CroweMar 2, 2017
  18. Junio C HamanoMar 2, 2017
  19. Mike CroweMar 2, 2017
  20. Torsten BögershausenMar 3, 2017
  21. Junio C HamanoMar 3, 2017
  22. Torsten BögershausenMar 4, 2017
  23. Junio C HamanoMar 4, 2017
  24. Torsten BögershausenMar 2, 2017
  25. Mike CroweMar 1, 2017
  26. Junio C HamanoMar 1, 2017
  27. Torsten BögershausenMar 2, 2017
  28. Mike CroweMar 3, 2017
  29. git status reports file modified when only line-endings have changed (was git diff --quiet exits with 1 on clean tree with CRLF conversions)Mike Crowe, Mar 2, 2017

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.