git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Csaba Henk <csaba@gluster.com>
To: git@vger.kernel.org
Subject: [PATCH v2] bundle: detect if bundle file cannot be created
Date: Fri, 27 Aug 2010 20:31:47 +0000 (UTC)	[thread overview]
Message-ID: <i597bj$vtg$1@dough.gmane.org> (raw)
In-Reply-To: 20100826092333.GB32617@acharya.in.gluster.com

bundle command silently died with no sign of failure if it
could not create the bundle file. (Eg.: its path resovles to a directory,
or the parent dir is sticky while file already exists and is owned
by someone else.)

Signed-off-by: Csaba Henk <csaba@gluster.com>
---
 bundle.c          |    6 ++++--
 t/t5704-bundle.sh |    7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/bundle.c b/bundle.c
index ff97adc..65ea26b 100644
--- a/bundle.c
+++ b/bundle.c
@@ -372,8 +372,10 @@ int create_bundle(struct bundle_header *header, const char *path,
 	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 'tags can be excluded by rev-list options' '
 
 '
 
+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 &&
-- 
1.7.2.2

      parent reply	other threads:[~2010-08-27 20:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-26  9:23 [PATCH] bundle: detect if bundle file cannot be created Csaba Henk
2010-08-26 17:26 ` Junio C Hamano
2010-08-27 20:31 ` Csaba Henk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='i597bj$vtg$1@dough.gmane.org' \
    --to=csaba@gluster.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).