From: Phillip Wood <phillip.wood123@gmail.com>
To: Elijah Newren <newren@gmail.com>, Josef Wolf <jw@raven.inka.de>,
git@vger.kernel.org
Cc: "brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: renormalize histroy with smudge/clean-filter
Date: Sat, 8 Feb 2025 11:14:57 +0000 [thread overview]
Message-ID: <ba65ce17-8768-4d60-aec6-badd12930b81@gmail.com> (raw)
In-Reply-To: <CABPp-BFGUa_DRBe1WLVfCOKh53+F15KxW_c_OZAMwZCxuAQCiw@mail.gmail.com>
Hi Elijah and Josef
On 08/02/2025 00:23, Elijah Newren wrote:
> On Fri, Feb 7, 2025 at 12:34 PM Josef Wolf <jw@raven.inka.de> wrote:
>> On Fri, Feb 07, 2025 at 06:01:43AM -0800, Elijah Newren wrote:
>>> On Fri, Feb 7, 2025 at 3:13 AM Chris Torek <chris.torek@gmail.com> wrote:
>>
> I also see I didn't look closely enough at Phillip's
> suggestion, which was:
>
> git rebase --root -x 'git add --renormalize . && { git diff --quiet
> --cached || git commit --amend --no-edit; }'
>
> which will work if you do a lot of manual work to resolve line ending
> difference conflicts. Since the git add at each step will modify the
> files on which the next commit is based, that causes the application
> of the subsequent commit to conflict,
Indeed, I'd missed that (like you I've not actually used any
smudge/clean filters)
> and you probably will have
> difficulty seeing those conflicts since they tend to just be line
> ending differences. But, mixing that with Brian's suggestion, you
> get:
>
> git rebase --root -X renormalize -x 'git add --renormalize . && {
> git diff --quiet --cached || git commit --amend --no-edit; }'
>
> which should probably work if you have a linear history
I've tried that out with a small modification in the script below which
seems to work. The modification is to add "--attr-source=$(git rev-parse
HEAD)" between "git" and "rebase" so that git always has a
.gitattributes file to read when rebasing commits that were made before
that file was added. I wonder if we should add something about
renormalizing a repository to the FAQ based on your footnote
> [1] The renormalize option to the merge machinery ensures that new
> blobs produced by the merge have normalized content, and avoid
> conflicts when the only differences between files are normalization
> ones. This option does not ensure that new trees only reference new
> content nor that they only reference normalized content; _any_
> pre-existing blobs in the repository are fair game for new trees to
> reference. As per the manual: "renormalize...This runs a virtual
> check-out and check-in of all three stages of a file when resolving a
> three-way merge..." So, the existing behavior of the renormalize
> option to rebase/cherry-pick/merge is correct. It may not be what you
> want, but I don't think cherry-picking/rebasing/merging with the
> renormalize option is the right tool for this job.
>
Best Wishes
Phillip
--- >8 ---
#!/bin/sh
set -e
d="$(mktemp -d)"
cd "$d"
git init
echo "The quick brown" >file
git add file
git commit -m line-1
echo "fox jumps over" >>file
git commit -a -m line-2
echo "the lazy dog" >>file
git commit -a -m line-3
echo "file filter=space" >.gitattributes
git config filter.space.clean "sed -e 's/ */ /g'"
git config filter.space.smudge cat
git add .gitattributes
git commit -a -m 'add .gitattributes'
git reset --hard HEAD
git --attr-source=$(git rev-parse HEAD) rebase --root -X renormalize \
-x 'git add --renormalize . && { git diff --cached --quiet || git
commit --amend --no-edit; }'
git log -p
next prev parent reply other threads:[~2025-02-08 11:15 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 21:47 renormalize histroy with smudge/clean-filter Josef Wolf
2025-02-05 22:55 ` brian m. carlson
2025-02-05 23:59 ` Josef Wolf
2025-02-06 0:29 ` brian m. carlson
2025-02-06 8:07 ` Elijah Newren
2025-02-06 13:40 ` Josef Wolf
2025-02-06 20:04 ` Josef Wolf
2025-02-07 6:10 ` Chris Torek
2025-02-07 10:45 ` Josef Wolf
2025-02-07 11:06 ` Torsten Bögershausen
2025-02-07 11:12 ` Chris Torek
2025-02-07 11:17 ` Chris Torek
2025-02-07 14:01 ` Elijah Newren
2025-02-07 20:32 ` Josef Wolf
2025-02-08 0:23 ` Elijah Newren
2025-02-08 11:14 ` Phillip Wood [this message]
2025-02-08 21:08 ` Josef Wolf
2025-02-08 21:43 ` Elijah Newren
2025-02-08 23:26 ` Josef Wolf
2025-02-09 2:33 ` D. Ben Knoble
2025-02-09 8:53 ` Josef Wolf
2025-02-09 7:21 ` Elijah Newren
2025-02-09 8:57 ` Josef Wolf
2025-02-10 17:51 ` D. Ben Knoble
2025-02-08 20:57 ` Josef Wolf
2025-02-08 21:56 ` Elijah Newren
2025-02-09 9:25 ` Josef Wolf
2025-02-09 11:14 ` Torsten Bögershausen
2025-02-09 15:09 ` Josef Wolf
2025-02-09 17:54 ` Josef Wolf
2025-02-09 18:01 ` Josef Wolf
2025-02-07 20:21 ` Josef Wolf
2025-02-07 15:39 ` Junio C Hamano
2025-02-06 10:13 ` Phillip Wood
2025-02-06 7:55 ` Elijah Newren
2025-02-06 19:00 ` Junio C Hamano
2025-02-11 23:57 ` renormalize histroy with smudge/clean-filter, again Josef Wolf
2025-02-12 6:12 ` Torsten Bögershausen
2025-02-12 8:18 ` Josef Wolf
2025-02-13 11:36 ` Collisions while cloning (was: Re: renormalize histroy with smudge/clean-filter, again) Josef Wolf
2025-02-13 16:40 ` Torsten Bögershausen
2025-02-14 20:03 ` renormalize histroy with smudge/clean-filter, again Josef Wolf
2025-02-14 20:21 ` brian m. carlson
2025-02-14 20:55 ` Josef Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba65ce17-8768-4d60-aec6-badd12930b81@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=git@vger.kernel.org \
--cc=jw@raven.inka.de \
--cc=newren@gmail.com \
--cc=phillip.wood@dunelm.org.uk \
--cc=sandals@crustytoothpaste.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).