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

Re: [PATCH] bundle: don't segfault on "git bundle <subcmd>"

From
HJHubert Jasudowicz <hubert.jasudowicz@stmcyber.pl>
Date
Dec 20, 2022, 13:50 UTC
Message-ID
<12f06dc2-8bfe-8cbe-c6b8-659f5bf92ea4@stmcyber.pl>
In-Reply-To
<patch-1.1-2319eb2ddbd-20221220T133941Z-avarab@gmail.com>
On 12/20/22 14:40, Ævar Arnfjörð Bjarmason wrote:> A proposed replacement for
Show 39 quoted lines
> https://lore.kernel.org/git/20221220123142.812965-1-hubertj@stmcyber.pl/;
> let's move forward & add a test rather than reverting away from the
> subcommand APIe
> 
>  builtin/bundle.c       | 2 +-
>  t/t6020-bundle-misc.sh | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/builtin/bundle.c b/builtin/bundle.c
> index c12c09f8549..61c76284768 100644
> --- a/builtin/bundle.c
> +++ b/builtin/bundle.c
> @@ -58,7 +58,7 @@ static int parse_options_cmd_bundle(int argc,
>  	int newargc;
>  	newargc = parse_options(argc, argv, NULL, options, usagestr,
>  			     PARSE_OPT_STOP_AT_NON_OPTION);
> -	if (argc < 1)
> +	if (!newargc)
>  		usage_with_options(usagestr, options);
>  	*bundle_file = prefix_filename(prefix, argv[0]);
>  	return newargc;
> diff --git a/t/t6020-bundle-misc.sh b/t/t6020-bundle-misc.sh
> index 833205125ab..3a1cf30b1d7 100755
> --- a/t/t6020-bundle-misc.sh
> +++ b/t/t6020-bundle-misc.sh
> @@ -11,6 +11,13 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
>  . ./test-lib.sh
>  . "$TEST_DIRECTORY"/lib-bundle.sh
>  
> +for cmd in create verify list-heads unbundle
> +do
> +	test_expect_success "usage: git bundle $cmd needs an argument" '
> +		test_expect_code 129 git bundle $cmd
> +	'
> +done
> +
>  # Create a commit or tag and set the variable with the object ID.
>  test_commit_setvar () {
>  	notick=
Seems to work. Thanks!
Tested-by: Hubert Jasudowicz <hubertj@stmcyber.pl>
Hubert Jasudowicz
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 5 of 11 in “Revert "builtin/bundle.c: let parse-options parse subcommands"”
  1. Revert "builtin/bundle.c: let parse-options parse subcommands"Hubert Jasudowicz, Dec 20, 2022
  2. Derrick StoleeDec 20, 2022
  3. Ævar Arnfjörð BjarmasonDec 20, 2022
  4. bundle: don't segfault on "git bundle <subcmd>"Ævar Arnfjörð Bjarmason, Dec 20, 2022
  5. Hubert JasudowiczDec 20, 2022
  6. Junio C HamanoDec 25, 2022
  7. Junio C HamanoDec 25, 2022
  8. 0/2 builtin/bundle.c: segfault fix style & error reporting follow-upÆvar Arnfjörð Bjarmason, Dec 27, 2022
  9. 1/2 builtin/bundle.c: remove superfluous "newargc" variableÆvar Arnfjörð Bjarmason, Dec 27, 2022
  10. 2/2 bundle <cmd>: have usage_msg_opt() note the missing "<file>"Ævar Arnfjörð Bjarmason, Dec 27, 2022
  11. Junio C HamanoDec 27, 2022

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.