git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* diff: should warn about EOL when --no-index ?
@ 2025-12-03 16:26 Kristoffer Haugsbakk
  2025-12-03 19:54 ` Torsten Bögershausen
  2025-12-03 22:06 ` Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: Kristoffer Haugsbakk @ 2025-12-03 16:26 UTC (permalink / raw)
  To: git

When using `git diff --no-index` on some CRLF files with my setup 
and config:

    warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it

To my mind, I’m saying that I don’t care about the working tree per
se. In particular, in this case, I’m just using git-diff(1) as a
difference utility on some non-Git files (this happens to be outside a
Git repository).

-- 
Kristoffer Haugsbakk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: diff: should warn about EOL when --no-index ?
  2025-12-03 16:26 diff: should warn about EOL when --no-index ? Kristoffer Haugsbakk
@ 2025-12-03 19:54 ` Torsten Bögershausen
  2025-12-04  8:24   ` Kristoffer Haugsbakk
  2025-12-03 22:06 ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Torsten Bögershausen @ 2025-12-03 19:54 UTC (permalink / raw)
  To: Kristoffer Haugsbakk; +Cc: git

On Wed, Dec 03, 2025 at 05:26:49PM +0100, Kristoffer Haugsbakk wrote:
> When using `git diff --no-index` on some CRLF files with my setup 
> and config:
> 
>     warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it
> 
> To my mind, I’m saying that I don’t care about the working tree per
> se. In particular, in this case, I’m just using git-diff(1) as a
> difference utility on some non-Git files (this happens to be outside a
> Git repository).
> 
> -- 
> Kristoffer Haugsbakk
> 

Not being an expert in `git diff --no-index`:
It seems as if Git reads the .gitconfig and possible .gitattributes here ?
Or what exact setup do yoe use, what is the value for
core.autocrlf
and do you have a .gitattributes file ?
Thinking about it: The warning may be not needed.
On the other hand: It seems as if something in your repo is
not as it should be ?
Because the repo should be normalized ?
And if it was, there would be no warning ?

What does
git ls-files --eol
give you ?

More information is welcome


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: diff: should warn about EOL when --no-index ?
  2025-12-03 16:26 diff: should warn about EOL when --no-index ? Kristoffer Haugsbakk
  2025-12-03 19:54 ` Torsten Bögershausen
@ 2025-12-03 22:06 ` Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2025-12-03 22:06 UTC (permalink / raw)
  To: Kristoffer Haugsbakk; +Cc: git

"Kristoffer Haugsbakk" <kristofferhaugsbakk@fastmail.com> writes:

> When using `git diff --no-index` on some CRLF files with my setup 
> and config:
>
>     warning: in the working copy of '<something>.csv', CRLF will be replaced by LF the next time Git touches it
>
> To my mind, I’m saying that I don’t care about the working tree per
> se. In particular, in this case, I’m just using git-diff(1) as a
> difference utility on some non-Git files (this happens to be outside a
> Git repository).

"git diff --no-index" is "we cannot bother to add our diff goodness
to other people's diff (like GNU) and instead we tweak our diff
machinery to work sufficiently well without repository", aka "better
alternative to GNU diff".  So you are correct to notice that it is
wrong to give the specific error/warning message that is only
applicable when the thing were found in a Git controlled working
tree.

But at the same time, the "better alternative" part comes from the
fact that our diff machinery can be tweaked with configuration
variables and attributes (mostly coloring, but diff algos and even
textconv filters may be good things that may want to be usable
outside a repository), so it would unfortunately not be a solution
to stop reading these Git controlled files.

The warning seems to come from check_global_conv_flags_eol() that is
called by crlf_to_git() and environment.c defines
global_conv_flags_eol to ensure everybody calling convert_to_git()
will get the warning when their contents would not round-trip
cleanly across CRLF-to-LF and then back with LF-to-CRLF.  Perhaps we
should disable it in "diff --no-index" but the right way to do so is
unclear.  E.g., if we want the same for "git grep --no-index", it
may be that "disable the warning because 'diff --index' is calling us"
is way too narrow and "disable the warning because we are running outside
a repository" may be a better alternative.  But do we want or not
want the same warning when we run "git diff --no-index" inside a Git
controlled working tree?  I am not sure.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: diff: should warn about EOL when --no-index ?
  2025-12-03 19:54 ` Torsten Bögershausen
@ 2025-12-04  8:24   ` Kristoffer Haugsbakk
  0 siblings, 0 replies; 4+ messages in thread
From: Kristoffer Haugsbakk @ 2025-12-04  8:24 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: git

On Wed, Dec 3, 2025, at 20:54, Torsten Bögershausen wrote:
> On Wed, Dec 03, 2025 at 05:26:49PM +0100, Kristoffer Haugsbakk wrote:
>>[[snip]
>> 
>
> Not being an expert in `git diff --no-index`:
> It seems as if Git reads the .gitconfig and possible .gitattributes here ?

Yes it has to do with my config or defaults. That doesn’t matter to
the question.

> Or what exact setup do yoe use, what is the value for
> core.autocrlf
> and do you have a .gitattributes file ?
> Thinking about it: The warning may be not needed.
> On the other hand: It seems as if something in your repo is
> not as it should be ?

It’s outside a Git repo.

> Because the repo should be normalized ?
> And if it was, there would be no warning ?
>
> What does
> git ls-files --eol
> give you ?
>
> More information is welcome

The warning could be about normalizing the other way for that
matter. I’m asking whether the warning should be there in this case.

I certainly don’t want to subject people to iteratively guess what 
my config is like.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-12-04  8:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 16:26 diff: should warn about EOL when --no-index ? Kristoffer Haugsbakk
2025-12-03 19:54 ` Torsten Bögershausen
2025-12-04  8:24   ` Kristoffer Haugsbakk
2025-12-03 22:06 ` Junio C Hamano

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).