Subject: Re: renormalize histroy with smudge/clean-filter

From: Junio C Hamano <[email-masked]>
Date: Thu, 06 Feb 2025 11:00:34 -0800

Elijah Newren <[email-masked]> writes:

> I kind of think we need a way to ask git "how would renormalization
> modify this buffer if it were at this path" short of creating a full
> index and checkout.

That makes it sound as if you are asking for "diff/patch" between
pre- and post- renormalization operation, but wouldn't the question
be more like "pretend this buffer content were at this path in a
checkout of this tree-ish.  Now compute what 'git add --renormalize'
would give us for that path".

What would it take?  

 - An equivalent of the in-core index (but you need to specify from
   which tree-ish it should be taken from) so that you can learn
   what attributes are attached to the path in question.  You may
   want to grab`filter`, `ident`, `working-tree-encoding`, etc. out
   of the attribute subsystem.

 - Access to the "config" data, to learn what exact commands to
   spawn to filter the buffer for, and what encoding and line
   terminating conventions are used for given path.  You may want to
   grab values of "filter.<name>.{clean,smudge}", "core.eol", etc.,
   for example.

 - A sandbox to safely run these external commands needed for
   smudge/clean filters.

It does not sound entirely trivial, but it does not look too much
of recket science, either.