On Wed, Feb 5, 2025 at 2:55 PM brian m. carlson <sandals@xxxxxxxxxxxxxxxxxxxx> wrote: > > On 2025-02-05 at 21:47:26, Josef Wolf wrote: > > Hello all, > > > > I have set up clean/smudge filters to normalzize files from an application to > > reduce the pain when those files are tracked by git. > > > > The clean/smudge filter work well on new commit and the result of > > smudge+smudge+clean is the same as the result of a simple clean, so the filter > > should be fine IMHO. > > > > But whenever I do any operations which introduce not yet normalized commits, I > > keep getting errors. > > Yes, this is known to occur. It notably happens with Git LFS, which > uses smudge and clean filters, and suffers from this same problem. > Renormalizing is indeed the right solution. > > > So to get rod of those errors, I'd like to also renormalize the history: > > > > $ git rebase --root --strategy renormalize > > error: Your local changes to the following files would be overwritten by > > merge: > > foo/bar/baz > > Please commit your changes or stash them before you merge. > > Aborting > > $ git add foo/bar/baz > > $ git commit -m renormalize foo/bar/baz > > $ git rebase --continue > > git: 'merge-renormalize' is not a git command. See 'git --help'. > > error: could not apply abcdef... Foo Bar Baz > > [ ... ] > > > > Huh? I never entered a command "merge-renormalize" > > When you use command like `--strategy foo` with a custom strategy, Git > calls a binary called `git merge-foo` to implement that strategy. So > while you didn't explicitly invoke that, when you used the nonstandard > strategy `renormalize` (which, by the way, does not exist), Git invoked > it when you rebased, since rebases by default use merges under the hood. > > > BTW: It does not make any difference whether I add "-c merge.renormalze=true" > > That option also does not exist. Can you tell us where you found such a > recommendation? If we've been misleading people in our documentation, > I'd like to fix. > > > What would be the proper way to renormalize history? > > The command that needs to be done is `git add --renormalize .` I think > you probably want to do is something like this: `git rebase --root -x > 'git add --renormalize . && git commit --amend --no-edit'`. > > You might also be able to use `git filter-repo` to do this in a nicer > way, but I'm not aware of how to do that. I've CCed the maintainer, > however, in case he or anyone else can provide an answer. `git add --renormalize .` requires a full checkout and an index. filter-repo was written to not require checkouts or an index; it should be able to operate in a bare repository as well. So, these simply don't go that well together. If we had a way to ask git "how would renormalization modify this buffer if it were at this path" we might be able to provide something (though that might require having a whole bunch of .gitattributes contents available, which might also make it tricky). Folks have requested it (https://github.com/newren/git-filter-repo/issues/375), and the final commenter provided a workaround that might be good enough for you, but 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.