Skip to content

Commit

Permalink
bundle: refuse to create empty bundle
Browse files Browse the repository at this point in the history
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 <gael.lhez@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information
glhez authored and dscho committed May 24, 2018
1 parent 8a8c948 commit b4f26fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,11 @@ int create_bundle(struct bundle_header *header, const char *path,
object_array_remove_duplicates(&revs.pending);

ref_count = write_bundle_refs(bundle_fd, &revs);
if (!ref_count)
die(_("Refusing to create empty bundle."));
else if (ref_count < 0)
if (ref_count <= 0) {
if (!ref_count)
error(_("Refusing to create empty bundle."));
goto err;
}

/* write pack */
if (write_pack_data(bundle_fd, &revs)) {
Expand Down
4 changes: 4 additions & 0 deletions t/t5607-clone-bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ test_expect_success 'prerequisites with an empty commit message' '
git bundle verify bundle
'

test_expect_success 'try to create a bundle with empty ref count' '
test_expect_code 1 git bundle create foobar.bundle master..master
'

test_done

0 comments on commit b4f26fa

Please sign in to comment.