Skip to content

Commit 6d0ba30

Browse files
glhezGit for Windows Build Agent
authored andcommitted
bundle: refuse to create empty bundle
When an user tries to create an empty bundle via `git bundle create <bundle> <revlist>` where <revlist> resolves to an empty list (for example, like `master..master`), the command fails and warns the user about how it don't want to create empty bundle. However, on Windows the .lock file was still open and could not be deleted properly. This patch fixes that issue. This closes #790 Signed-off-by: Gaël Lhez <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent bfcf2ea commit 6d0ba30

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
@@ -450,10 +450,11 @@ int create_bundle(struct bundle_header *header, const char *path,
450450
object_array_remove_duplicates(&revs.pending);
451451

452452
ref_count = write_bundle_refs(bundle_fd, &revs);
453-
if (!ref_count)
454-
die(_("Refusing to create empty bundle."));
455-
else if (ref_count < 0)
453+
if (ref_count <= 0) {
454+
if (!ref_count)
455+
error(_("Refusing to create empty bundle."));
456456
goto err;
457+
}
457458

458459
/* write pack */
459460
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)