Merge branch 'ch/maint-cannot-create-bundle-error'

* ch/maint-cannot-create-bundle-error:
  bundle: detect if bundle file cannot be created
diff --git a/bundle.c b/bundle.c
index ff97adc..65ea26b 100644
--- a/bundle.c
+++ b/bundle.c
@@ -372,8 +372,10 @@
 	close(rls.in);
 	if (finish_command(&rls))
 		return error ("pack-objects died");
-	if (!bundle_to_stdout)
-		commit_lock_file(&lock);
+	if (!bundle_to_stdout) {
+		if (commit_lock_file(&lock))
+			die_errno("cannot create '%s'", path);
+	}
 	return 0;
 }
 
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index ddc3dc5..728ccd8 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -30,6 +30,13 @@
 
 '
 
+test_expect_success 'die if bundle file cannot be created' '
+
+	mkdir adir &&
+	test_must_fail git bundle create adir --all
+
+'
+
 test_expect_failure 'bundle --stdin' '
 
 	echo master | git bundle create stdin-bundle.bdl --stdin &&