]> git.ipfire.org Git - thirdparty/git.git/commit - fast-import.c
fast-import: add options for rewriting submodules
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sat, 22 Feb 2020 20:17:49 +0000 (20:17 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 28 Feb 2020 17:53:41 +0000 (09:53 -0800)
commit1bdca816412910e1206c15ef47f2a8a6b369b831
treee725694e6add4e43c656a16a196d9cef11bd9a6e
parentd9db599ca85b008faedc1d5e771e28b6fb648c4e
fast-import: add options for rewriting submodules

When converting a repository using submodules from one hash algorithm to
another, it is necessary to rewrite the submodules from the old
algorithm to the new algorithm, since only references to submodules, not
their contents, are written to the fast-export stream. Without rewriting
the submodules, fast-import fails with an "Invalid dataref" error when
encountering a submodule in another algorithm.

Add a pair of options, --rewrite-submodules-from and
--rewrite-submodules-to, that take a list of marks produced by
fast-export and fast-import, respectively, when processing the
submodule. Use these marks to map the submodule commits from the old
algorithm to the new algorithm.

We read marks into two corresponding struct mark_set objects and then
perform a mapping from the old to the new using a hash table. This lets
us reuse the same mark parsing code that is used elsewhere and allows us
to efficiently read and match marks based on their ID, since mark files
need not be sorted.

Note that because we're using a khash table for the object IDs, and this
table copies values of struct object_id instead of taking references to
them, it's necessary to zero the struct object_id values that we use to
insert and look up in the table. Otherwise, we would end up with SHA-1
values that don't match because of whatever stack garbage might be left
in the unused area.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-fast-import.txt
fast-import.c
t/t9300-fast-import.sh