Support gitlinks in fast-import.

Currently fast-import/export cannot be used for
repositories with submodules. This patch extends
the relevant programs to make them correctly
process gitlinks.

Links can be represented by two forms of the
Modify command:

M 160000 SHA1 some/path

which sets the link target explicitly, or

M 160000 :mark some/path

where the mark refers to a commit. The latter
form can be used by importing tools to build
all submodules simultaneously in one physical
repository, and then simply fetch them apart.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Alexander Gavrilov
2008-07-19 16:21:24 +04:00
committed by Junio C Hamano
parent 4a3fedd597
commit 03db4525d3
5 changed files with 227 additions and 5 deletions

View File

@ -1868,6 +1868,7 @@ static void file_change_m(struct branch *b)
case S_IFREG | 0644:
case S_IFREG | 0755:
case S_IFLNK:
case S_IFGITLINK:
case 0644:
case 0755:
/* ok */
@ -1900,7 +1901,20 @@ static void file_change_m(struct branch *b)
p = uq.buf;
}
if (inline_data) {
if (S_ISGITLINK(mode)) {
if (inline_data)
die("Git links cannot be specified 'inline': %s",
command_buf.buf);
else if (oe) {
if (oe->type != OBJ_COMMIT)
die("Not a commit (actually a %s): %s",
typename(oe->type), command_buf.buf);
}
/*
* Accept the sha1 without checking; it expected to be in
* another repository.
*/
} else if (inline_data) {
static struct strbuf buf = STRBUF_INIT;
if (p != uq.buf) {