summaryrefslogtreecommitdiff
path: root/builtin-fast-export.c
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2008-07-19 12:21:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-19 18:25:51 (GMT)
commit03db4525d38119f7778d6e9117f27c47db8466d4 (patch)
treeee8126cbb922debfe445a54658c5a57dca4cc3ca /builtin-fast-export.c
parent4a3fedd5976ae9175cc418876d17ca568278b426 (diff)
downloadgit-03db4525d38119f7778d6e9117f27c47db8466d4.zip
git-03db4525d38119f7778d6e9117f27c47db8466d4.tar.gz
git-03db4525d38119f7778d6e9117f27c47db8466d4.tar.bz2
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>
Diffstat (limited to 'builtin-fast-export.c')
-rw-r--r--builtin-fast-export.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 76f3167..a443d59 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -136,9 +136,18 @@ static void show_filemodify(struct diff_queue_struct *q,
if (is_null_sha1(spec->sha1))
printf("D %s\n", spec->path);
else {
- struct object *object = lookup_object(spec->sha1);
- printf("M %06o :%d %s\n", spec->mode,
- get_object_mark(object), spec->path);
+ /*
+ * Links refer to objects in another repositories;
+ * output the SHA-1 verbatim.
+ */
+ if (S_ISGITLINK(spec->mode))
+ printf("M %06o %s %s\n", spec->mode,
+ sha1_to_hex(spec->sha1), spec->path);
+ else {
+ struct object *object = lookup_object(spec->sha1);
+ printf("M %06o :%d %s\n", spec->mode,
+ get_object_mark(object), spec->path);
+ }
}
}
}
@@ -196,8 +205,10 @@ static void handle_commit(struct commit *commit, struct rev_info *rev)
diff_root_tree_sha1(commit->tree->object.sha1,
"", &rev->diffopt);
+ /* Export the referenced blobs, and remember the marks. */
for (i = 0; i < diff_queued_diff.nr; i++)
- handle_object(diff_queued_diff.queue[i]->two->sha1);
+ if (!S_ISGITLINK(diff_queued_diff.queue[i]->two->mode))
+ handle_object(diff_queued_diff.queue[i]->two->sha1);
mark_next_object(&commit->object);
if (!is_encoding_utf8(encoding))