All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bundle: detect if bundle file cannot be created
@ 2010-08-26  9:23 Csaba Henk
  2010-08-26 17:26 ` Junio C Hamano
  2010-08-27 20:31 ` [PATCH v2] " Csaba Henk
  0 siblings, 2 replies; 3+ messages in thread
From: Csaba Henk @ 2010-08-26  9:23 UTC (permalink / raw)
  To: git

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.)
---
 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..3eb4ca2 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 bundle file");
+	}
 	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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] bundle: detect if bundle file cannot be created
  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 ` [PATCH v2] " Csaba Henk
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2010-08-26 17:26 UTC (permalink / raw)
  To: Csaba Henk; +Cc: git

Csaba Henk <csaba@gluster.com> writes:

> 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.)
> ---

Sign-off?

> diff --git a/bundle.c b/bundle.c
> index ff97adc..3eb4ca2 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 bundle file");
> +	}

You would want to parrot the path given by the caller, perhaps like this?

	die_errno("cannot create '%s'", path)

This function tries to report error to the caller in some places but
rudely dies in some other places, so dying here is not a serious offence.

> 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
> +
> +'

I like it ;-)

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] bundle: detect if bundle file cannot be created
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Csaba Henk @ 2010-08-27 20:31 UTC (permalink / raw)
  To: git

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-08-27 20:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH v2] " Csaba Henk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.