Skip to content

Commit

Permalink
Merge branch 'tc/bundle-with-tag-remove-workaround'
Browse files Browse the repository at this point in the history
"git bundle create" with an annotated tag on the positive end of
the revision range had a workaround code for older limitation in
the revision walker, which has become unnecessary.

* tc/bundle-with-tag-remove-workaround:
  bundle: remove unneeded code
  • Loading branch information
gitster committed Dec 19, 2024
2 parents 930f2b4 + dd1072d commit 1df37ef
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 30 deletions.
30 changes: 0 additions & 30 deletions bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,36 +420,6 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
e->name);
goto skip_write_ref;
}
/*
* If you run "git bundle create bndl v1.0..v2.0", the
* name of the positive ref is "v2.0" but that is the
* commit that is referenced by the tag, and not the tag
* itself.
*/
if (!oideq(&oid, &e->item->oid)) {
/*
* Is this the positive end of a range expressed
* in terms of a tag (e.g. v2.0 from the range
* "v1.0..v2.0")?
*/
struct commit *one = lookup_commit_reference(revs->repo, &oid);
struct object *obj;

if (e->item == &(one->object)) {
/*
* Need to include e->name as an
* independent ref to the pack-objects
* input, so that the tag is included
* in the output; otherwise we would
* end up triggering "empty bundle"
* error.
*/
obj = parse_object_or_die(&oid, e->name);
obj->flags |= SHOWN;
add_pending_object(revs, obj, e->name);
}
goto skip_write_ref;
}

ref_count++;
write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz);
Expand Down
44 changes: 44 additions & 0 deletions t/t6020-bundle-misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,50 @@ test_expect_success 'unfiltered bundle with --objects' '
test_cmp expect actual
'

test_expect_success 'full bundle upto annotated tag' '
git bundle create v2.bdl \
v2 &&
git bundle verify v2.bdl |
make_user_friendly_and_stable_output >actual &&
format_and_save_expect <<-EOF &&
The bundle contains this ref:
<TAG-2> refs/tags/v2
The bundle records a complete history.
$HASH_MESSAGE
EOF
test_cmp expect actual
'

test_expect_success 'clone from full bundle upto annotated tag' '
git clone --mirror v2.bdl tag-clone.git &&
git -C tag-clone.git show-ref |
make_user_friendly_and_stable_output >actual &&
cat >expect <<-\EOF &&
<TAG-2> refs/tags/v2
EOF
test_cmp expect actual
'

test_expect_success 'incremental bundle between two annotated tags' '
git bundle create v1-v2.bdl \
v1..v2 &&
git bundle verify v1-v2.bdl |
make_user_friendly_and_stable_output >actual &&
format_and_save_expect <<-EOF &&
The bundle contains this ref:
<TAG-2> refs/tags/v2
The bundle requires these 2 refs:
<COMMIT-E> Z
<COMMIT-B> Z
$HASH_MESSAGE
EOF
test_cmp expect actual
'

for filter in "blob:none" "tree:0" "tree:1" "blob:limit=100"
do
test_expect_success "filtered bundle: $filter" '
Expand Down

0 comments on commit 1df37ef

Please sign in to comment.