From 61821aaa12ed698f2e94bb15fea958c598e4f231 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 1 Mar 2012 22:40:48 +0100 Subject: t5510: refactor bundle->pack conversion It's not so much a conversion as a "strip everything up to and including the first blank line", but it will come in handy again. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t5510-fetch.sh | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index e0af4c4e62..6508d8ab13 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -14,6 +14,14 @@ test_bundle_object_count () { test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l) } +convert_bundle_to_pack () { + while read x && test -n "$x" + do + :; + done + cat +} + test_expect_success setup ' echo >file original && git add file && @@ -207,13 +215,7 @@ test_expect_success 'unbundle 1' ' test_expect_success 'bundle 1 has only 3 files ' ' cd "$D" && - ( - while read x && test -n "$x" - do - :; - done - cat - ) bundle.pack && + convert_bundle_to_pack bundle.pack && git index-pack bundle.pack && test_bundle_object_count bundle.pack 3 ' @@ -230,13 +232,7 @@ test_expect_success 'bundle does not prerequisite objects' ' git add file2 && git commit -m add.file2 file2 && git bundle create bundle3 -1 HEAD && - ( - while read x && test -n "$x" - do - :; - done - cat - ) bundle.pack && + convert_bundle_to_pack bundle.pack && git index-pack bundle.pack && test_bundle_object_count bundle.pack 3 ' -- cgit v1.2.3 From aa9828561e562a0b9ca559be4225de679b8e8be3 Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 1 Mar 2012 22:40:49 +0100 Subject: t5510: ensure we stay in the toplevel test dir The last test descended into a subdir without ever re-emerging, which is not so nice to the next test writer. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- t/t5510-fetch.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index 6508d8ab13..d7eca5dbab 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -430,14 +430,16 @@ test_expect_success 'fetch --dry-run' ' ' test_expect_success "should be able to fetch with duplicate refspecs" ' - mkdir dups && - cd dups && - git init && - git config branch.master.remote three && - git config remote.three.url ../three/.git && - git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* && - git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* && - git fetch three + mkdir dups && + ( + cd dups && + git init && + git config branch.master.remote three && + git config remote.three.url ../three/.git && + git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* && + git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* && + git fetch three + ) ' test_done -- cgit v1.2.3 From efe4be12490ab684786c48135731c4d2648bbecc Mon Sep 17 00:00:00 2001 From: Thomas Rast Date: Thu, 1 Mar 2012 22:40:51 +0100 Subject: bundle: keep around names passed to add_pending_object() The 'name' field passed to add_pending_object() is used to later deduplicate in object_array_remove_duplicates(). git-bundle had a bug in this area since 18449ab (git-bundle: avoid packing objects which are in the prerequisites, 2007-03-08): it passed the name of each boundary object in a static buffer. In other words, all that object_array_remove_duplicates() saw was the name of the *last* added boundary object. The recent switch to a strbuf in bc2fed4 (bundle: use a strbuf to scan the log for boundary commits, 2012-02-22) made this slightly worse: we now free the buffer at the end, so it is not even guaranteed that it still points into addressable memory by the time object_array_remove_ duplicates looks at it. On the plus side however, it was now detectable by valgrind. The fix is easy: pass a copy of the string to add_pending_object. Signed-off-by: Thomas Rast Signed-off-by: Junio C Hamano --- bundle.c | 2 +- t/t5510-fetch.sh | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/bundle.c b/bundle.c index 4497343e56..6c4695eb91 100644 --- a/bundle.c +++ b/bundle.c @@ -273,7 +273,7 @@ int create_bundle(struct bundle_header *header, const char *path, if (!get_sha1_hex(buf.buf + 1, sha1)) { struct object *object = parse_object(sha1); object->flags |= UNINTERESTING; - add_pending_object(&revs, object, buf.buf); + add_pending_object(&revs, object, xstrdup(buf.buf)); } } else if (!get_sha1_hex(buf.buf, sha1)) { struct object *object = parse_object(sha1); diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh index d7eca5dbab..9d72b16393 100755 --- a/t/t5510-fetch.sh +++ b/t/t5510-fetch.sh @@ -442,4 +442,19 @@ test_expect_success "should be able to fetch with duplicate refspecs" ' ) ' +test_expect_success 'all boundary commits are excluded' ' + test_commit base && + test_commit oneside && + git checkout HEAD^ && + test_commit otherside && + git checkout master && + test_tick && + git merge otherside && + ad=$(git log --no-walk --format=%ad HEAD) && + git bundle create twoside-boundary.bdl master --since="$ad" && + convert_bundle_to_pack twoside-boundary.pack && + pack=$(git index-pack --fix-thin --stdin