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

Re: [PATCH v1 0/1] t6038-merge-text-auto.sh

From
Junio C Hamano <gitster@pobox.com>
Date
May 30, 2016, 18:00 UTC
Message-ID
<xmqqzir7o286.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1464627642-23994-1-git-send-email-tboegi@web.de>
tboegi@web.de writes:
Show 10 quoted lines
> This is a little bit of a hen-and-egg problem:
> The problem comes up after the "unified auto handling".
> In theory, it should have been since before:
> get_sha1_from_index() says:
>
>  * We might be in the middle of a merge, in which
>  * case we would read stage #2 (ours).
>
> This seams wrong, as in the merge we sometimes need to
> look at "theirs".

The two comment you quoted is absolutely the right thing to do. "In a merge, we sometimes need to look at 'theirs'" is like saying "When we are dong 'git add', we need to look at what is in the working tree". It is total red herring.

Step back and think why we even look at what in the index in the first place; it is to decide if we want or do not want to disable the automatic CRLF -> LF conversion. And think again the reason why do we look at the index.

There may be a line with CRLF line endings in the new contents, whether it came from a merge, cherry-pick, patch application, or plain-simple "git add" from the working tree. Auto-CRLF usually says "We want CRLF turned into LF". But the user misconfigured and for this path the user might not want the conversion take place, in which case you would disable the conversion. Where do you take that hint "the user might have misconfigured?" from? By looking at what the user _started_ her update from. If the state before this "we need to replace the blob in the index with a new contents, so we need to hash the new contents to come up with the updated blob" started contains CRLF already, that may be a hint--if we apply the CRLF->LF conversion on the original, even if the "new contents" were identical to what she already had, we would end up changing the blob with her current configuration. Hence we disable.

Isn't that the reasoning behind that "safe auto-crlf" thing?

The new contents getting integrated into her current state may have CRLF, and if a merge or a cherry-pick leaves conflicts, they may be stored in stage #3. But paying attention to that to decide if we want to disable Auto-CRLF conversion is simply wrong; you should look at the CRLF in stage #3 as purely something that might need to be converted, not something that affects the decision if it needs to be converted, just like you view CRLF in a working tree file when you do "git add"..

Imagine that you started from a history where somebody recorded a text file with CRLF in the blob, unconverted. Later the project decided to express their text with LF to support cross-platform development better, and sets up the Auto-CRLF. Your user is working near the tip of that history after the eol correction happened. Now she gets a pull-request of a branch that forked from an old point in the history, before the eol correction and full of CRLF. Yes, to integrate the change being proposed, she needs to look at "theirs"; that's the whole point of a "merge". Why should she revert the eol correction her history has by getting fooled by the fact that the update was based on a part of the history before the eol correction?

Previous: tboegi@web.deNext: Junio C Hamano
Message 43 of 53 in “Bug report: Duplicate CRLF rewrite warnings on commit”
  1. Adam DinwoodieMay 13, 2016
  2. Junio C HamanoMay 13, 2016
  3. Torsten BögershausenMay 14, 2016
  4. Adam DinwoodieMay 14, 2016
  5. Jeff KingMay 13, 2016
  6. Junio C HamanoMay 13, 2016
  7. Jeff KingMay 13, 2016
  8. 0/1 Quickfix ?No duplicate CRLF rewrite warnings on committboegi@web.de, May 15, 2016
  9. 1/1 No duplicate CRLF rewrite warnings on committboegi@web.de, May 15, 2016
  10. Eric SunshineMay 15, 2016
  11. 0/3 CRLF-Handling: bug fix around ce_compare_data()tboegi@web.de, May 15, 2016
  12. 1/3 t6038; use crlf on all platformstboegi@web.de, May 15, 2016
  13. Eric SunshineMay 15, 2016
  14. 2/3 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 15, 2016
  15. Eric SunshineMay 15, 2016
  16. 3/3 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 15, 2016
  17. Eric SunshineMay 15, 2016
  18. Junio C HamanoMay 15, 2016
  19. 0/1 CRLF-Handling: bug fix around ce_compare_data()tboegi@web.de, May 16, 2016
  20. Junio C HamanoMay 16, 2016
  21. Torsten BögershausenMay 17, 2016
  22. 1/1 t6038; use crlf on all platformstboegi@web.de, May 17, 2016
  23. Junio C HamanoMay 17, 2016
  24. 0/2 CRLF: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 17, 2016
  25. 1/2 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 17, 2016
  26. 2/2 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 17, 2016
  27. Junio C HamanoMay 17, 2016
  28. Torsten BögershausenMay 18, 2016
  29. Torsten BögershausenMay 18, 2016
  30. 0/2 CRLF: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 19, 2016
  31. Junio C HamanoMay 19, 2016
  32. 1/2 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 19, 2016
  33. 2/2 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 19, 2016
  34. Junio C HamanoMay 19, 2016
  35. 1/2 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 20, 2016
  36. 2/2 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 20, 2016
  37. Junio C HamanoMay 20, 2016
  38. 1/2 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 21, 2016
  39. 2/2 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 21, 2016
  40. Junio C HamanoMay 24, 2016
  41. 1/1 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 16, 2016
  42. 0/1 t6038-merge-text-auto.shtboegi@web.de, May 30, 2016
  43. Junio C HamanoMay 30, 2016
  44. Junio C HamanoMay 30, 2016
  45. 1/1 t6038: different eol for "Merge addition of text=auto"tboegi@web.de, May 30, 2016
  46. 0/3 unified auto CRLF handling, V2tboegi@web.de, Jun 7, 2016
  47. 1/3 convert: unify the "auto" handling of CRLFtboegi@web.de, Jun 7, 2016
  48. 2/3 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, Jun 7, 2016
  49. 3/3 Correct ce_compare_data() in a middle of a mergetboegi@web.de, Jun 7, 2016
  50. 0/3 CRLF-Handling: bug fix around ce_compare_data()tboegi@web.de, May 15, 2016
  51. 1/3 read-cache: factor out get_sha1_from_index() helpertboegi@web.de, May 15, 2016
  52. 2/3 convert: ce_compare_data() checks for a sha1 of a pathtboegi@web.de, May 15, 2016
  53. 3/3 t6038; use crlf on all platformstboegi@web.de, May 15, 2016

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.