Skip to content

Commit 580f005

Browse files
committed
Merge pull request git-for-windows#797 from glhez/master
`git bundle create <bundle>` leaks handle the revlist is empty.
2 parents 1acebcb + f4a4c04 commit 580f005

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bundle.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,10 +454,11 @@ int create_bundle(struct bundle_header *header, const char *path,
454454
object_array_remove_duplicates(&revs.pending);
455455

456456
ref_count = write_bundle_refs(bundle_fd, &revs);
457-
if (!ref_count)
458-
die(_("Refusing to create empty bundle."));
459-
else if (ref_count < 0)
457+
if (ref_count <= 0) {
458+
if (!ref_count)
459+
error(_("Refusing to create empty bundle."));
460460
goto err;
461+
}
461462

462463
/* write pack */
463464
if (write_pack_data(bundle_fd, &revs)) {

t/t5607-clone-bundle.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,8 @@ test_expect_success 'prerequisites with an empty commit message' '
7171
git bundle verify bundle
7272
'
7373

74+
test_expect_success 'try to create a bundle with empty ref count' '
75+
test_expect_code 1 git bundle create foobar.bundle master..master
76+
'
77+
7478
test_done

0 commit comments

Comments
 (0)