aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2007-03-08 00:43:05 +0100
committerJunio C Hamano <junkio@cox.net>2007-03-07 17:38:48 -0800
commit18449ab0e9754ae04ae2f232449241ac361f3db4 (patch)
tree9675c9712e5f40ff25338b2f19db2ab19d0a3ead
parent8315588b59bea45c4b82451cc3ac337fa5c68526 (diff)
downloadgit-18449ab0e9754ae04ae2f232449241ac361f3db4.tar.gz
git-18449ab0e9754ae04ae2f232449241ac361f3db4.tar.xz
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>
-rw-r--r--builtin-bundle.c15
-rwxr-xr-xt/t5510-fetch.sh11
2 files changed, 23 insertions, 3 deletions
diff --git a/builtin-bundle.c b/builtin-bundle.c
index 3b3bc2582..70d447919 100644
--- a/builtin-bundle.c
+++ b/builtin-bundle.c
@@ -305,6 +305,10 @@ static int create_bundle(struct bundle_header *header, const char *path,
/* write signature */
write_or_die(bundle_fd, bundle_signature, strlen(bundle_signature));
+ /* init revs to list objects for pack-objects later */
+ save_commit_buffer = 0;
+ init_revisions(&revs, NULL);
+
/* write prerequisites */
memcpy(argv_boundary + 3, argv + 1, argc * sizeof(const char *));
argv_boundary[0] = "rev-list";
@@ -316,8 +320,15 @@ static int create_bundle(struct bundle_header *header, const char *path,
if (pid < 0)
return -1;
while ((i = read_string(out, buffer, sizeof(buffer))) > 0)
- if (buffer[0] == '-')
+ if (buffer[0] == '-') {
+ unsigned char sha1[20];
write_or_die(bundle_fd, buffer, i);
+ if (!get_sha1_hex(buffer + 1, sha1)) {
+ struct object *object = parse_object(sha1);
+ object->flags |= UNINTERESTING;
+ add_pending_object(&revs, object, buffer);
+ }
+ }
while ((i = waitpid(pid, &status, 0)) < 0)
if (errno != EINTR)
return error("rev-list died");
@@ -325,8 +336,6 @@ static int create_bundle(struct bundle_header *header, const char *path,
return error("rev-list died %d", WEXITSTATUS(status));
/* write references */
- save_commit_buffer = 0;
- init_revisions(&revs, NULL);
revs.tag_objects = 1;
revs.tree_objects = 1;
revs.blob_objects = 1;
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index ad589dd0d..ee3f397a9 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -128,4 +128,15 @@ test_expect_success 'unbundle 2' '
test "tip" = "$(git log -1 --pretty=oneline master | cut -b42-)"
'
+test_expect_success 'bundle does not prerequisite objects' '
+ cd "$D" &&
+ touch file2 &&
+ git add file2 &&
+ git commit -m add.file2 file2 &&
+ git bundle create bundle3 -1 HEAD &&
+ sed "1,4d" < bundle3 > bundle.pack &&
+ git index-pack bundle.pack &&
+ test 4 = $(git verify-pack -v bundle.pack | wc -l)
+'
+
test_done