From: Geoffrey Irving <irving@naml.us>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] git fast-export: add --no-data option
Date: Sat, 25 Jul 2009 09:45:19 -0400 [thread overview]
Message-ID: <7f9d599f0907250645s6e6f9b81w3cf20f07eff088eb@mail.gmail.com> (raw)
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>
---
I've already done all I need with this change (for now, at least), but
here it is in case it proves useful to others. Amusingly, rewriting
history with
git fast-export --no-data <branch> | <python-script> | git fast-import
is now much, much faster than the equivalent
git filter-branch --prune-empty --msg-filter ...
I haven't investigated why.
Documentation/git-fast-export.txt | 7 +++++++
builtin-fast-export.c | 8 +++++++-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-fast-export.txt
b/Documentation/git-fast-export.txt
index 0c9eb56..47a96dd 100644
--- a/Documentation/git-fast-export.txt
+++ b/Documentation/git-fast-export.txt
@@ -71,6 +71,13 @@ marks the same across runs.
allow that. So fake a tagger to be able to fast-import the
output.
+--no-data::
+ Skip output of blob objects and instead refer to blobs via
+ their original SHA-1 hash. This is useful when rewriting the
+ directory structure or history of a repository without
+ touching the contents of individual files. Note that the
+ resulting stream can only be used by a repository which
+ already contains the necessary objects.
EXAMPLES
--------
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 9a8a6fc..ac72791 100644
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
@@ -25,6 +25,7 @@ static const char *fast_export_usage[] = {
static int progress;
static enum { VERBATIM, WARN, STRIP, ABORT } signed_tag_mode = ABORT;
static int fake_missing_tagger;
+static int no_data;
static int parse_opt_signed_tag_mode(const struct option *opt,
const char *arg, int unset)
@@ -101,6 +102,9 @@ static void handle_object(const unsigned char *sha1)
char *buf;
struct object *object;
+ if (no_data)
+ return;
+
if (is_null_sha1(sha1))
return;
@@ -158,7 +162,7 @@ static void show_filemodify(struct diff_queue_struct *q,
* Links refer to objects in another repositories;
* output the SHA-1 verbatim.
*/
- if (S_ISGITLINK(spec->mode))
+ if (no_data || S_ISGITLINK(spec->mode))
printf("M %06o %s %s\n", spec->mode,
sha1_to_hex(spec->sha1), spec->path);
else {
@@ -504,6 +508,8 @@ int cmd_fast_export(int argc, const char **argv,
const char *prefix)
"Import marks from this file"),
OPT_BOOLEAN(0, "fake-missing-tagger", &fake_missing_tagger,
"Fake a tagger when tags lack one"),
+ OPT_BOOLEAN(0, "no-data", &no_data,
+ "Skip output of blob data"),
OPT_END()
};
--
1.6.3.1
next reply other threads:[~2009-07-25 13:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-25 13:45 Geoffrey Irving [this message]
2009-07-25 14:28 ` [PATCH] git fast-export: add --no-data option Johannes Schindelin
2009-07-25 17:25 ` Junio C Hamano
2009-07-25 17:44 ` Johannes Schindelin
2009-07-27 12:48 ` Geoffrey Irving
2009-07-27 18:49 ` Johannes Schindelin
2009-07-28 2:20 ` Geoffrey Irving
2009-07-28 4:11 ` Stephen Boyd
2009-07-28 8:01 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7f9d599f0907250645s6e6f9b81w3cf20f07eff088eb@mail.gmail.com \
--to=irving@naml.us \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox