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

[PATCH 1/2] builtin/bundle.c: remove superfluous "newargc" variable

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Dec 27, 2022, 18:39 UTC
Message-ID
<patch-1.2-357cea183d6-20221227T183708Z-avarab@gmail.com>
In-Reply-To
<cover-0.2-00000000000-20221227T183708Z-avarab@gmail.com>

As noted in 891cb09db6c (bundle: don't segfault on "git bundle <subcmd>", 2022-12-20) the "newargc" in this function is redundant to using our own "argc". Let's refactor the function to avoid needlessly introducing another variable.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/bundle.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 61c76284768..3d1ad220ff8 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -55,13 +55,12 @@ static int parse_options_cmd_bundle(int argc,
 		const char * const usagestr[],
 		const struct option options[],
 		char **bundle_file) {
-	int newargc;
-	newargc = parse_options(argc, argv, NULL, options, usagestr,
+	argc = parse_options(argc, argv, NULL, options, usagestr,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
-	if (!newargc)
+	if (!argc)
 		usage_with_options(usagestr, options);
 	*bundle_file = prefix_filename(prefix, argv[0]);
-	return newargc;
+	return argc;
 }
 
 static int cmd_bundle_create(int argc, const char **argv, const char *prefix) {
-- 
2.39.0.1106.gf45ba805d1a
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 9 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.