From f6d273d3ab9a7e1d3ce079feb70bb7662bc04935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20Lhez?= Date: Wed, 22 Jun 2016 23:30:18 +0200 Subject: [PATCH] bundle: refuse to create empty bundle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When an user tries to create an empty bundle via `git bundle create ` where 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 https://github.com/git-for-windows/git/issues/790 Signed-off-by: Gaƫl Lhez Signed-off-by: Johannes Schindelin --- bundle.c | 7 ++++--- t/t5607-clone-bundle.sh | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bundle.c b/bundle.c index 24cbe40986..874696e4e4 100644 --- a/bundle.c +++ b/bundle.c @@ -457,10 +457,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)) { diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh index 348d9b3bc7..f84b875950 100755 --- a/t/t5607-clone-bundle.sh +++ b/t/t5607-clone-bundle.sh @@ -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