builtin-bundle.c - use stream buffered input for rev-list
git-bundle create on cygwin was nearly unusable due to 1 character at a time (unbuffered) reading from an exec'ed process. Fix by using fdopen to get a buffered stream. Results for "time git bundle create test.bdl v1.0.3..v1.5.2" are: before this patch: cygwin linux real 1m38.828s 0m3.578s user 0m12.122s 0m2.896s sys 1m28.215s 0m0.692s after this patch: real 0m3.688s 0m2.835s user 0m3.075s 0m2.731s sys 0m1.075s 0m0.149s Signed-off-by: Mark Levedahl <mdl123@verizon.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Mark Levedahl committed
Aug 10, 2007 at 18:29 UTC
442b67a55972e69a054eb1206bbbdf044532130a
1 file changed
+5
-2
builtin-bundle.c
+5
-2
@@ -207,6 +207,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
207
char buffer[1024];
208
struct rev_info revs;
209
struct child_process rls;
210
+ FILE *rls_fout;
211
212
/*
213
* NEEDSWORK: this should use something like lock-file
@@ -236,10 +237,11 @@ static int create_bundle(struct bundle_header *header, const char *path,
237
rls.git_cmd = 1;
238
if (start_command(&rls))
239
return -1;
239
- while ((i = read_string(rls.out, buffer, sizeof(buffer))) > 0) {
240
+ rls_fout = fdopen(rls.out, "r");
241
+ while (fgets(buffer, sizeof(buffer), rls_fout)) {
242
unsigned char sha1[20];
243
if (buffer[0] == '-') {
242
- write_or_die(bundle_fd, buffer, i);
244
+ write_or_die(bundle_fd, buffer, strlen(buffer));
245
if (!get_sha1_hex(buffer + 1, sha1)) {
246
struct object *object = parse_object(sha1);
247
object->flags |= UNINTERESTING;
@@ -250,6 +252,7 @@ static int create_bundle(struct bundle_header *header, const char *path,
252
object->flags |= SHOWN;
253
}
254
}
255
+ fclose(rls_fout);
256
if (finish_command(&rls))
257
return error("rev-list died");
258