Skip to content

Commit 92b7aac

Browse files
committed
Merge branch 'tr/maint-bundle-boundary' into maint
"git bundle" did not record boundary commits correctly when there are many of them. By Thomas Rast * tr/maint-bundle-boundary: bundle: keep around names passed to add_pending_object() t5510: ensure we stay in the toplevel test dir t5510: refactor bundle->pack conversion
2 parents fce8b5d + efe4be1 commit 92b7aac

File tree

2 files changed

+36
-23
lines changed

2 files changed

+36
-23
lines changed

bundle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ int create_bundle(struct bundle_header *header, const char *path,
273273
if (!get_sha1_hex(buf.buf + 1, sha1)) {
274274
struct object *object = parse_object(sha1);
275275
object->flags |= UNINTERESTING;
276-
add_pending_object(&revs, object, buf.buf);
276+
add_pending_object(&revs, object, xstrdup(buf.buf));
277277
}
278278
} else if (!get_sha1_hex(buf.buf, sha1)) {
279279
struct object *object = parse_object(sha1);

t/t5510-fetch.sh

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ test_bundle_object_count () {
1414
test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l)
1515
}
1616

17+
convert_bundle_to_pack () {
18+
while read x && test -n "$x"
19+
do
20+
:;
21+
done
22+
cat
23+
}
24+
1725
test_expect_success setup '
1826
echo >file original &&
1927
git add file &&
@@ -206,13 +214,7 @@ test_expect_success 'unbundle 1' '
206214

207215
test_expect_success 'bundle 1 has only 3 files ' '
208216
cd "$D" &&
209-
(
210-
while read x && test -n "$x"
211-
do
212-
:;
213-
done
214-
cat
215-
) <bundle1 >bundle.pack &&
217+
convert_bundle_to_pack <bundle1 >bundle.pack &&
216218
git index-pack bundle.pack &&
217219
test_bundle_object_count bundle.pack 3
218220
'
@@ -229,13 +231,7 @@ test_expect_success 'bundle does not prerequisite objects' '
229231
git add file2 &&
230232
git commit -m add.file2 file2 &&
231233
git bundle create bundle3 -1 HEAD &&
232-
(
233-
while read x && test -n "$x"
234-
do
235-
:;
236-
done
237-
cat
238-
) <bundle3 >bundle.pack &&
234+
convert_bundle_to_pack <bundle3 >bundle.pack &&
239235
git index-pack bundle.pack &&
240236
test_bundle_object_count bundle.pack 3
241237
'
@@ -433,14 +429,31 @@ test_expect_success 'fetch --dry-run' '
433429
'
434430

435431
test_expect_success "should be able to fetch with duplicate refspecs" '
436-
mkdir dups &&
437-
cd dups &&
438-
git init &&
439-
git config branch.master.remote three &&
440-
git config remote.three.url ../three/.git &&
441-
git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
442-
git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
443-
git fetch three
432+
mkdir dups &&
433+
(
434+
cd dups &&
435+
git init &&
436+
git config branch.master.remote three &&
437+
git config remote.three.url ../three/.git &&
438+
git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
439+
git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
440+
git fetch three
441+
)
442+
'
443+
444+
test_expect_success 'all boundary commits are excluded' '
445+
test_commit base &&
446+
test_commit oneside &&
447+
git checkout HEAD^ &&
448+
test_commit otherside &&
449+
git checkout master &&
450+
test_tick &&
451+
git merge otherside &&
452+
ad=$(git log --no-walk --format=%ad HEAD) &&
453+
git bundle create twoside-boundary.bdl master --since="$ad" &&
454+
convert_bundle_to_pack <twoside-boundary.bdl >twoside-boundary.pack &&
455+
pack=$(git index-pack --fix-thin --stdin <twoside-boundary.pack) &&
456+
test_bundle_object_count .git/objects/pack/pack-${pack##pack }.pack 3
444457
'
445458

446459
test_done

0 commit comments

Comments
 (0)