@matheusbsbs / matheus-bagliano / commits / 18449ab0e9
Fork 0

git-bundle: avoid packing objects which are in the prerequisites

When saying something like "--since=1.day.ago" or "--max-count=5", git-bundle finds the boundary commits which are recorded as prerequisites. However, it failed to tell pack-objects _not_ to pack the objects which are in these. Fix that. And add a test for that. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Mar 8, 2007 at 00:43 UTC 18449ab0e9754ae04ae2f232449241ac361f3db4
2 files changed +23 -3
builtin-bundle.c
+12 -3
@@ -305,6 +305,10 @@ static int create_bundle(struct bundle_header *header, const char *path,
305 /* write signature */
306 write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature));
307
308 + /* init revs to list objects for pack-objects later */
309 + save_commit_buffer = 0;
310 + init_revisions(&revs, NULL);
311 +
312 /* write prerequisites */
313 memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *));
314 argv_boundary[0] = "rev-list";
@@ -316,8 +320,15 @@ static int create_bundle(struct bundle_header *header, const char *path,
320 if (pid < 0)
321 return -1;
322 while ((i = read_string(out, buffer, sizeof(buffer))) > 0)
319 - if (buffer[0] == '-')
323 + if (buffer[0] == '-') {
324 + unsigned char sha1[20];
325 write_or_die(bundle_fd, buffer, i);
326 + if (!get_sha1_hex(buffer + 1, sha1)) {
327 + struct object *object = parse_object(sha1);
328 + object->flags |= UNINTERESTING;
329 + add_pending_object(&revs, object, buffer);
330 + }
331 + }
332 while ((i = waitpid(pid, &status, 0)) < 0)
333 if (errno != EINTR)
334 return error("rev-list died");
@@ -325,8 +336,6 @@ static int create_bundle(struct bundle_header *header, const char *path,
336 return error("rev-list died %d", WEXITSTATUS(status));
337
338 /* write references */
328 - save_commit_buffer = 0;
329 - init_revisions(&revs, NULL);
339 revs.tag_objects = 1;
340 revs.tree_objects = 1;
341 revs.blob_objects = 1;
t/t5510-fetch.sh
+11
@@ -128,4 +128,15 @@ test_expect_success 'unbundle 2' '
128 test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
129 '
130
131 +test_expect_success 'bundle does not prerequisite objects' '
132 + cd "$D" &&
133 + touch file2 &&
134 + git add file2 &&
135 + git commit -m add.file2 file2 &&
136 + git bundle create bundle3 -1 HEAD &&
137 + sed "1,4d" < bundle3 > bundle.pack &&
138 + git index-pack bundle.pack &&
139 + test 4 = $(git verify-pack -v bundle.pack | wc -l)
140 +'
141 +
142 test_done