From a5c1780a0355a71b9fb70f1f1977ce726ee5b8d8 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Fri, 20 Apr 2007 11:23:45 -0400 Subject: [PATCH 1/3] Don't repack existing objects in fast-import Some users of fast-import have been trying to use it to rewrite commits and trees, an activity where the all of the relevant blobs are already available from the existing packfiles. In such a case we don't want to repack a blob, even if the frontend application has supplied us the raw data rather than a mark or a SHA-1 name. I'm intentionally only checking the packfiles that existed when fast-import started and am always ignoring all loose object files. We ignore loose objects because fast-import tends to operate on a very large number of objects in a very short timespan, and it is usually creating new objects, not reusing existing ones. In such a situtation the majority of the objects will not be found in the existing packfiles, nor will they be loose object files. If the frontend application really wants us to look at loose object files, then they can just repack the repository before running fast-import. Signed-off-by: Shawn O. Pearce --- fast-import.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fast-import.c b/fast-import.c index cdd629d6b..e3290df3d 100644 --- a/fast-import.c +++ b/fast-import.c @@ -904,6 +904,12 @@ static int store_object( if (e->offset) { duplicate_count_by_type[type]++; return 1; + } else if (find_sha1_pack(sha1, packed_git)) { + e->type = type; + e->pack_id = MAX_PACK_ID; + e->offset = 1; /* just not zero! */ + duplicate_count_by_type[type]++; + return 1; } if (last && last->data && last->depth < max_depth) { @@ -2021,6 +2027,7 @@ static void import_marks(const char *input_file) e = insert_object(sha1); e->type = type; e->pack_id = MAX_PACK_ID; + e->offset = 1; /* just not zero! */ } insert_mark(mark, e); } @@ -2086,6 +2093,7 @@ int main(int argc, const char **argv) if (i != argc) usage(fast_import_usage); + prepare_packed_git(); start_packfile(); for (;;) { read_next_command(); From 46f6178a3f4e7a5bf8b47da0f3cc5c998d907ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 24 Apr 2007 13:51:04 +0200 Subject: [PATCH 2/3] fix importing of subversion tars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add a / between the prefix and name fields of the tar archive if prefix is non-empty. Signed-off-by: Uwe Kleine-König Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 5585a8b2c..184214689 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -64,7 +64,12 @@ } print FI "\n"; - my $path = "$prefix$name"; + my $path; + if ($prefix) { + $path = "$prefix/$name"; + } else { + $path = "$name"; + } $files{$path} = [$next_mark++, $mode]; $commit_time = $mtime if $mtime > $commit_time; From 00be8dcc1aca3c1c1a94b39f0563d30d1fa89290 Mon Sep 17 00:00:00 2001 From: Sami Farin Date: Tue, 24 Apr 2007 22:56:02 +0300 Subject: [PATCH 3/3] fast-import: size_t vs ssize_t size_t is unsigned, so (n < 0) is never true. Signed-off-by: Shawn O. Pearce --- fast-import.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fast-import.c b/fast-import.c index e3290df3d..c4c8cb905 100644 --- a/fast-import.c +++ b/fast-import.c @@ -673,7 +673,7 @@ static void fixup_header_footer(void) buf = xmalloc(buf_sz); for (;;) { - size_t n = xread(pack_fd, buf, buf_sz); + ssize_t n = xread(pack_fd, buf, buf_sz); if (!n) break; if (n < 0)