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

[PATCH v2 1/2] push: unmark a local variable as static

From
BWBrandon Williams <bmwill@google.com>
Date
Mar 31, 2017, 23:56 UTC
Message-ID
<20170331235623.166408-2-bmwill@google.com>
In-Reply-To
<20170331235623.166408-1-bmwill@google.com>

There isn't any obvious reason for the 'struct string_list push_options' and 'struct string_list_item *item' to be marked as static, so unmark them as being static. Also, clear the push_options string_list to prevent memory leaking.

Signed-off-by: Brandon Williams <bmwill@google.com>
---
 builtin/push.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/push.c b/builtin/push.c
index 5c22e9f2e..a597759d8 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -510,8 +510,8 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 	int push_cert = -1;
 	int rc;
 	const char *repo = NULL;	/* default repository */
-	static struct string_list push_options = STRING_LIST_INIT_DUP;
-	static struct string_list_item *item;
+	struct string_list push_options = STRING_LIST_INIT_DUP;
+	const struct string_list_item *item;
 
 	struct option options[] = {
 		OPT__VERBOSITY(&verbosity),
@@ -584,6 +584,7 @@ int cmd_push(int argc, const char **argv, const char *prefix)
 			die(_("push options must not have new line characters"));
 
 	rc = do_push(repo, flags, &push_options);
+	string_list_clear(&push_options, 0);
 	if (rc == -1)
 		usage_with_options(push_usage, options);
 	else
-- 
2.12.2.564.g063fe858b8-goog
Previous: Brandon WilliamsNext: Jonathan Nieder
Message 5 of 19 in “push: propagate push-options with --recurse-submodules”
  1. push: propagate push-options with --recurse-submodulesBrandon Williams, Mar 31, 2017
  2. Jonathan NiederMar 31, 2017
  3. Brandon WilliamsMar 31, 2017
  4. 0/2 propagate push-optionsBrandon Williams, Mar 31, 2017
  5. 1/2 push: unmark a local variable as staticBrandon Williams, Mar 31, 2017
  6. Jonathan NiederApr 1, 2017
  7. Brandon WilliamsApr 1, 2017
  8. 2/2 push: propagate push-options with --recurse-submodulesBrandon Williams, Mar 31, 2017
  9. Jonathan NiederApr 1, 2017
  10. Jacob KellerApr 6, 2017
  11. Brandon WilliamsApr 6, 2017
  12. 0/5 propagating push-options, remote and refspecBrandon Williams, Apr 5, 2017
  13. 2/5 push: propagate push-options with --recurse-submodulesBrandon Williams, Apr 5, 2017
  14. 5/5 push: propagate remote and refspec with --recurse-submodulesBrandon Williams, Apr 5, 2017
  15. 4/5 submodule--helper: add push-check subcommandBrandon Williams, Apr 5, 2017
  16. 1/5 push: unmark a local variable as staticBrandon Williams, Apr 5, 2017
  17. 3/5 remote: expose parse_push_refspec functionBrandon Williams, Apr 5, 2017
  18. Junio C HamanoApr 11, 2017
  19. Brandon WilliamsApr 11, 2017

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.