{"thread":{"id":"64575","subject":"diff: should warn about EOL when --no-index ?","startedAt":"2025-12-03T16:28:11Z","lastAt":"2025-12-04T08:24:44Z","messageCount":4,"participants":["Kristoffer Haugsbakk","Torsten Bögershausen","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"531630","messageId":"03643900-db0b-48b7-93a7-4d96632af57c@app.fastmail.com","threadId":"64575","inReplyTo":null,"subject":"diff: should warn about EOL when --no-index ?","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-12-03T16:26:49Z","receivedAt":"2025-12-03T16:28:11Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"When using `git diff --no-index` on some CRLF files with my setup \nand config:\n\n    warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it\n\nTo my mind, I’m saying that I don’t care about the working tree per\nse. In particular, in this case, I’m just using git-diff(1) as a\ndifference utility on some non-Git files (this happens to be outside a\nGit repository).\n\n-- \nKristoffer Haugsbakk\n"},{"id":"531634","messageId":"20251203195424.GB13919@tb-raspi4","threadId":"64575","inReplyTo":"03643900-db0b-48b7-93a7-4d96632af57c@app.fastmail.com","subject":"Re: diff: should warn about EOL when --no-index ?","fromName":"Torsten Bögershausen","fromEmail":"tboegi@web.de","sentAt":"2025-12-03T19:54:24Z","receivedAt":"2025-12-03T19:54:35Z","isPatch":false,"sender":{"key":"tboegi@web.de","avatar":"https://avatars.githubusercontent.com/u/7138363?v=4"},"body":"On Wed, Dec 03, 2025 at 05:26:49PM +0100, Kristoffer Haugsbakk wrote:\n> When using `git diff --no-index` on some CRLF files with my setup \n> and config:\n> \n>     warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it\n> \n> To my mind, I’m saying that I don’t care about the working tree per\n> se. In particular, in this case, I’m just using git-diff(1) as a\n> difference utility on some non-Git files (this happens to be outside a\n> Git repository).\n> \n> -- \n> Kristoffer Haugsbakk\n> \n\nNot being an expert in `git diff --no-index`:\nIt seems as if Git reads the .gitconfig and possible .gitattributes here ?\nOr what exact setup do yoe use, what is the value for\ncore.autocrlf\nand do you have a .gitattributes file ?\nThinking about it: The warning may be not needed.\nOn the other hand: It seems as if something in your repo is\nnot as it should be ?\nBecause the repo should be normalized ?\nAnd if it was, there would be no warning ?\n\nWhat does\ngit ls-files --eol\ngive you ?\n\nMore information is welcome\n\n"},{"id":"531636","messageId":"xmqq4iq76x0u.fsf@gitster.g","threadId":"64575","inReplyTo":"03643900-db0b-48b7-93a7-4d96632af57c@app.fastmail.com","subject":"Re: diff: should warn about EOL when --no-index ?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-12-03T22:06:09Z","receivedAt":"2025-12-03T22:06:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kristoffer Haugsbakk\" <kristofferhaugsbakk@fastmail.com> writes:\n\n> When using `git diff --no-index` on some CRLF files with my setup \n> and config:\n>\n>     warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it\n>\n> To my mind, I’m saying that I don’t care about the working tree per\n> se. In particular, in this case, I’m just using git-diff(1) as a\n> difference utility on some non-Git files (this happens to be outside a\n> Git repository).\n\n\"git diff --no-index\" is \"we cannot bother to add our diff goodness\nto other people's diff (like GNU) and instead we tweak our diff\nmachinery to work sufficiently well without repository\", aka \"better\nalternative to GNU diff\".  So you are correct to notice that it is\nwrong to give the specific error/warning message that is only\napplicable when the thing were found in a Git controlled working\ntree.\n\nBut at the same time, the \"better alternative\" part comes from the\nfact that our diff machinery can be tweaked with configuration\nvariables and attributes (mostly coloring, but diff algos and even\ntextconv filters may be good things that may want to be usable\noutside a repository), so it would unfortunately not be a solution\nto stop reading these Git controlled files.\n\nThe warning seems to come from check_global_conv_flags_eol() that is\ncalled by crlf_to_git() and environment.c defines\nglobal_conv_flags_eol to ensure everybody calling convert_to_git()\nwill get the warning when their contents would not round-trip\ncleanly across CRLF-to-LF and then back with LF-to-CRLF.  Perhaps we\nshould disable it in \"diff --no-index\" but the right way to do so is\nunclear.  E.g., if we want the same for \"git grep --no-index\", it\nmay be that \"disable the warning because 'diff --index' is calling us\"\nis way too narrow and \"disable the warning because we are running outside\na repository\" may be a better alternative.  But do we want or not\nwant the same warning when we run \"git diff --no-index\" inside a Git\ncontrolled working tree?  I am not sure.\n\n\n"},{"id":"531646","messageId":"c3aeed96-01e2-4572-80a8-a9eef0cd1315@app.fastmail.com","threadId":"64575","inReplyTo":"20251203195424.GB13919@tb-raspi4","subject":"Re: diff: should warn about EOL when --no-index ?","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-12-04T08:24:13Z","receivedAt":"2025-12-04T08:24:44Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Wed, Dec 3, 2025, at 20:54, Torsten Bögershausen wrote:\n> On Wed, Dec 03, 2025 at 05:26:49PM +0100, Kristoffer Haugsbakk wrote:\n>>[[snip]\n>> \n>\n> Not being an expert in `git diff --no-index`:\n> It seems as if Git reads the .gitconfig and possible .gitattributes here ?\n\nYes it has to do with my config or defaults. That doesn’t matter to\nthe question.\n\n> Or what exact setup do yoe use, what is the value for\n> core.autocrlf\n> and do you have a .gitattributes file ?\n> Thinking about it: The warning may be not needed.\n> On the other hand: It seems as if something in your repo is\n> not as it should be ?\n\nIt’s outside a Git repo.\n\n> Because the repo should be normalized ?\n> And if it was, there would be no warning ?\n>\n> What does\n> git ls-files --eol\n> give you ?\n>\n> More information is welcome\n\nThe warning could be about normalizing the other way for that\nmatter. I’m asking whether the warning should be there in this case.\n\nI certainly don’t want to subject people to iteratively guess what \nmy config is like.\n"}]}