git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] bundle: detect if bundle file cannot be created

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 26, 2010, 17:26 UTC
Message-ID
<7vpqx5l1yc.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100826092333.GB32617@acharya.in.gluster.com>
Csaba Henk <csaba@gluster.com> writes:
Show 5 quoted lines
> 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?
Show 14 quoted lines
> 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.

Show 14 quoted lines
> 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.
Previous: Csaba HenkNext: Csaba Henk
Message 2 of 3 in “bundle: detect if bundle file cannot be created”
  1. bundle: detect if bundle file cannot be createdCsaba Henk, Aug 26, 2010
  2. Junio C HamanoAug 26, 2010
  3. bundle: detect if bundle file cannot be createdCsaba Henk, Aug 27, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.