@matheusbsbs / matheus-bagliano / commits / 79559f27be
Fork 0

git fast-export: add --no-data option

When using git fast-export and git fast-import to rewrite the history of a repository with large binary files, almost all of the time is spent dealing with blobs. This is extremely inefficient if all we want to do is rewrite the commits and tree structure. --no-data skips the output of blobs and writes SHA-1s instead of marks, which provides a massive speedup. Signed-off-by: Geoffrey Irving <irving@naml.us> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Geoffrey Irving committed Jul 27, 2009 at 22:20 UTC 79559f27be7e2963213d840a857dee92c579843f
2 files changed +16 -1
Documentation/git-fast-export.txt
+8
@@ -82,6 +82,14 @@ marks the same across runs.
82 allow that. So fake a tagger to be able to fast-import the
83 output.
84
85 +--no-data::
86 + Skip output of blob objects and instead refer to blobs via
87 + their original SHA-1 hash. This is useful when rewriting the
88 + directory structure or history of a repository without
89 + touching the contents of individual files. Note that the
90 + resulting stream can only be used by a repository which
91 + already contains the necessary objects.
92 +
93 [git-rev-list-args...]::
94 A list of arguments, acceptable to 'git-rev-parse' and
95 'git-rev-list', that specifies the specific objects and references
builtin-fast-export.c
+8 -1
@@ -26,6 +26,7 @@ static int progress;
26 static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT;
27 static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT;
28 static int fake_missing_tagger;
29 +static int no_data;
30
31 static int parse_opt_signed_tag_mode(const struct option *opt,
32 const char *arg, int unset)
@@ -116,6 +117,9 @@ static void handle_object(const unsigned char *sha1)
117 char *buf;
118 struct object *object;
119
120 + if (no_data)
121 + return;
122 +
123 if (is_null_sha1(sha1))
124 return;
125
@@ -173,7 +177,7 @@ static void show_filemodify(struct diff_queue_struct *q,
177 * Links refer to objects in another repositories;
178 * output the SHA-1 verbatim.
179 */
176 - if (S_ISGITLINK(spec->mode))
180 + if (no_data || S_ISGITLINK(spec->mode))
181 printf("M %06o %s %s\n", spec->mode,
182 sha1_to_hex(spec->sha1), spec->path);
183 else {
@@ -580,6 +584,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
584 "Import marks from this file"),
585 OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
586 "Fake a tagger when tags lack one"),
587 + { OPTION_NEGBIT, 0, "data", &no_data, NULL,
588 + "Skip output of blob data",
589 + PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },
590 OPT_END()
591 };
592