Skip to content

Commit 60e3f26

Browse files
committed
Merge pull request #797 from glhez/master
`git bundle create <bundle>` leaks handle the revlist is empty.
2 parents 7ad1114 + 81def5c commit 60e3f26

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

bundle.c

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

517517
ref_count = write_bundle_refs(bundle_fd, &revs);
518-
if (!ref_count)
519-
die(_("Refusing to create empty bundle."));
520-
else if (ref_count < 0)
518+
if (ref_count <= 0) {
519+
if (!ref_count)
520+
error(_("Refusing to create empty bundle."));
521521
goto err;
522+
}
522523

523524
/* write pack */
524525
if (write_pack_data(bundle_fd, &revs)) {

t/tgfw790-git-bundle.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
test_description='
3+
test git-bundle under git for Windows
4+
5+
When we select an empty set of commit (like git bundle create foobar.bundle master..master),
6+
we should not have problem with the foobar.bundle.lock being locked (especially on Windows).
7+
'
8+
9+
. ./test-lib.sh
10+
11+
test_expect_failure 'try to create a bundle with empty ref count' '
12+
git bundle create foobar.bundle master..master
13+
'
14+
15+
test_done

0 commit comments

Comments
 (0)