git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Wolf <jw@raven.inka.de>
To: git@vger.kernel.org
Subject: Re: renormalize histroy with smudge/clean-filter
Date: Sat, 8 Feb 2025 21:57:09 +0100	[thread overview]
Message-ID: <20250208205709.GH30202@raven.inka.de> (raw)
In-Reply-To: <CABPp-BFGUa_DRBe1WLVfCOKh53+F15KxW_c_OZAMwZCxuAQCiw@mail.gmail.com>

On Fri, Feb 07, 2025 at 04:23:45PM -0800, Elijah Newren wrote:
> I may have misunderstood what folks were saying in my reading &
> skimming of this thread.  I thought some folks were suggesting
> 
>    git rebase --root -X renormalize
>
> as a way to renormalize the history, assuming you have linear history.

Yes. And this did not work.

Then there was Brian's suggenstion, so I tried:

   git rebase --root -x 'git add --renormalize . && git commit --amend --no-edit'

which won't work because not every commit touches a filtered file, so I also
tried:

   git rebase --root -x 'git add --renormalize . && git status --quiet -uno | git commit --amend --no-edit'

which also did not work. Looks like git-status always exits with success. Why?

> I was arguing against that; it's not going to work and isn't meant
> to[1].  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, and you probably will have
> difficulty seeing those conflicts since they tend to just be line
> ending differences.

This did not work also: generated LOTS of conflicts.

Oh, have I mentioned that I am not only about line endings? Yes, I mentioned
it in the very first mail. In addition to line endings, I am also about XML
files from a proprietary application which reorders the XML-elements into a
random order every time it ist run. So the clean-filter needs to sort the
XML elements into some "canonical" order.

> 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; }'

Yes, this finally works, IF

   git add --renormalize . && git commit --amend --no-edit

is run before starting the rebase process.

BTW: why won't

    git rebase --root -X renormalize \
     -x 'git add --renormalize .' \
     -x 'git diff --quiet --cached || git commit --amend --no-edit'

work?

> Were you trying one of these three?  Or something else?

Yes. And even more...

Oh, the application I am talking about also tracks changes in those XML files
in corresponding hash files. I added those hash files into .gitignore and
re-create them in the smudge-filter. This works fine so far, but it also
generates lots of conflicts during renormalization. So I created a helper for
the -x parameter of the renormalize-process to also remove those hash files:

   #! /bin/sh -e
   
   find gt8/ETS/Projekte/* -maxdepth 1 \
      -name "[BDGIUP].ets5hash" -o \
      -name "P-*.ets5hash" \
      -print0 \
     | xargs -r0 git status --short -uno \
     | sed -n "s/^...\(.*\.ets5hash\)$/\1/p" \
     | xargs -r git rm -f git --attr-source=$(git rev-parse HEAD) diff --quiet --cached || \
           git --attr-source=$(git rev-parse HEAD) commit --amend --no-edit
   
   git --attr-source=$(git rev-parse HEAD) add --renormalize .
   git --attr-source=$(git rev-parse HEAD) diff --quiet --cached || \
       git --attr-source=$(git rev-parse HEAD) commit --amend --no-edit

But no matter how I construt this, the renormalize keeps conflicting on these
files. Whehn I do

    git rm -f gt8/ETS/Projekte/XXX/U.ets5hash
    git --attr-source=$(git rev-parse HEAD) commit --amend --no-edit
    git rebase --continue

manually, it works fine. Why won't the git-rm work when called from git-rebase directly?

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

OK.

But then, non-normalized content should go through the clean-filter before it
is handed over to diff/merge when filtering is active. At least when --renormalize
is in effect. Using smudged content for diff/merge operations is a sure recipe
for failure.

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

A virtual check-out and check-in should result in smudge+clean. Running this
on smudged content results in smudge+smudge+clean. Which by definition is
equivalent to a simple clean. No conflicts shoud happen, then.

So the _description_ looks correct. But where do the conflicts coming from?

> It may not be what you want

I don't see how the description matches actual behaviour

-- 
Josef Wolf
jw@raven.inka.de

  parent reply	other threads:[~2025-02-08 20:58 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
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 [this message]
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=20250208205709.GH30202@raven.inka.de \
    --to=jw@raven.inka.de \
    --cc=git@vger.kernel.org \
    /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).