git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Round-tripping fast-export/import changes commit hashes

From
anatoly techtonik <techtonik@gmail.com>
Date
Dec 11, 2022, 18:30 UTC
Message-ID
<CAPkN8xJ_B_t7L6bErsFB+rp6fzy7PO55myWqyJWPNbTgiQ69ow@mail.gmail.com>
In-Reply-To
<CABPp-BEqvmSaqVrK=nQsk-8PNXq6Pzq4Y-=RopYwTDjtyitAuw@mail.gmail.com>
On Tue, Aug 10, 2021 at 8:58 PM Elijah Newren <newren@gmail.com> wrote:
Show 23 quoted lines
>
> On Tue, Aug 10, 2021 at 8:51 AM anatoly techtonik <techtonik@gmail.com> wrote:
> >
> > On Mon, Aug 9, 2021 at 9:15 PM Elijah Newren <newren@gmail.com> wrote:
> > >
>
> [2] https://lore.kernel.org/git/CABPp-BH4dcsW52immJpTjgY5LjaVfKrY9MaUOnKT3byi2tBPpg@mail.gmail.com/
>
> Signed commits is just one issue, and you'll have to add special code
> to handle a bunch of other special cases if you go down this route.
> I'd rephrase the problem.  You want to know when _your tool_ (e.g.
> reposurgeon since you refer to it multiple times; I'm guessing you're
> contributing to it?) has not modified a commit or any of its
> ancestors, and when it hasn't, then _your tool_ should remove that
> commit from the fast-export stream and replace any references to it by
> the original commit's object id.  I outlined how to do this in [2],
> referenced above, making use of the --show-original-ids flag to
> fast-export.  If you do that, then for any commits which you haven't
> modified (including not modifying any of its ancestors), then you'll
> keep the same commits as-is with no stripping of gpg-signatures or
> canonicalization of objects, so that you'll have the exact same commit
> IDs.  Further, you can do this today, without any changes to git
> fast-export or git fast-import.
Took me a while to process the reply. Let's recap.

I want to make a roundtrip export/import of https://github.com/simons-public/protonfixes which should get exactly the same repository.

# --- fast-export to exported.txt git clone https://github.com/simons-public/protonfixes git -C protonfixes fast-export --all > exported.txt # --- check revision of the repo git -C protonfixes rev-parse HEAD # 681411ba8ceb5d2d790e674eb7a5b98951d426e6

# --- fast-import into new repo git init newrepo git -C newrepo fast-import < exported.txt # --- checking revision of the new repo git -C newrepo rev-parse HEAD # 9888762d7857d9721f0c354e7fc187a199754a4b

Hashes don't match. The roundtrip fails.
Let's see if --reference-excluded-parents helps.

# --- export below produces the same export stream as above git -C protonfixes fast-export --reference-excluded-parents --all > exported_parents.txt

Because fast-import/fast-export don't work, you propose to keep the old repo around until it is clear which commits I am going to modify. Then make a new fast-export starting from the first commit I am going to modify with --reference-excluded-parents flag. Is that correct so far?

Then given this partial export and old repo, how to init the new repo that fast-import can apply its tail there?

What if I have multiple commits that I modify, but I don't know which of their parents was first? And when I touch commits from different branches, how to recreate their parent history intact in one repo?

-- 
anatoly t.
Previous: Elijah NewrenNext: Elijah Newren
Message 14 of 21 in “Round-tripping fast-export/import changes commit hashes”
  1. anatoly techtonikFeb 27, 2021
  2. Elijah NewrenFeb 27, 2021
  3. anatoly techtonikFeb 28, 2021
  4. Ævar Arnfjörð BjarmasonFeb 28, 2021
  5. anatoly techtonikMar 1, 2021
  6. Junio C HamanoMar 1, 2021
  7. anatoly techtonikMar 2, 2021
  8. Johannes SixtMar 3, 2021
  9. Junio C HamanoMar 4, 2021
  10. anatoly techtonikAug 9, 2021
  11. Elijah NewrenAug 9, 2021
  12. anatoly techtonikAug 10, 2021
  13. Elijah NewrenAug 10, 2021
  14. anatoly techtonikDec 11, 2022
  15. Elijah NewrenJan 13, 2023
  16. Elijah NewrenMar 1, 2021
  17. Ævar Arnfjörð BjarmasonMar 1, 2021
  18. Elijah NewrenMar 1, 2021
  19. anatoly techtonikMar 2, 2021
  20. Ævar Arnfjörð BjarmasonMar 1, 2021
  21. anatoly techtonikMar 2, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.