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

[PATCH 2/5] fetch: rename file-scope global "transport" to "gtransport"

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 7, 2013, 23:30 UTC
Message-ID
<1375918242-4655-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1375918242-4655-1-git-send-email-gitster@pobox.com>

Although many functions in this file take a "struct transport" as a parameter, "fetch_one()" assigns to the global singleton instance which is a file-scope static, in order to allow a parameterless signal handler unlock_pack() to access it.

Rename the variable to gtransport to make sure these uses stand out.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/fetch.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index d784b2e..636b47f 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -36,7 +36,7 @@ static int tags = TAGS_DEFAULT, unshallow;
 static const char *depth;
 static const char *upload_pack;
 static struct strbuf default_rla = STRBUF_INIT;
-static struct transport *transport;
+static struct transport *gtransport;
 static const char *submodule_prefix = "";
 static const char *recurse_submodules_default;
 
@@ -95,8 +95,8 @@ static struct option builtin_fetch_options[] = {
 
 static void unlock_pack(void)
 {
-	if (transport)
-		transport_unlock_pack(transport);
+	if (gtransport)
+		transport_unlock_pack(gtransport);
 }
 
 static void unlock_pack_on_signal(int signo)
@@ -818,13 +818,13 @@ static int do_fetch(struct transport *transport,
 
 static void set_option(const char *name, const char *value)
 {
-	int r = transport_set_option(transport, name, value);
+	int r = transport_set_option(gtransport, name, value);
 	if (r < 0)
 		die(_("Option \"%s\" value \"%s\" is not valid for %s"),
-			name, value, transport->url);
+		    name, value, gtransport->url);
 	if (r > 0)
 		warning(_("Option \"%s\" is ignored for %s\n"),
-			name, transport->url);
+			name, gtransport->url);
 }
 
 static int get_one_remote_for_fetch(struct remote *remote, void *priv)
@@ -949,8 +949,8 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 		die(_("No remote repository specified.  Please, specify either a URL or a\n"
 		    "remote name from which new revisions should be fetched."));
 
-	transport = transport_get(remote, NULL);
-	transport_set_verbosity(transport, verbosity, progress);
+	gtransport = transport_get(remote, NULL);
+	transport_set_verbosity(gtransport, verbosity, progress);
 	if (upload_pack)
 		set_option(TRANS_OPT_UPLOADPACK, upload_pack);
 	if (keep)
@@ -983,10 +983,10 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)
 	sigchain_push_common(unlock_pack_on_signal);
 	atexit(unlock_pack);
 	refspec = parse_fetch_refspec(ref_nr, refs);
-	exit_code = do_fetch(transport, refspec, ref_nr);
+	exit_code = do_fetch(gtransport, refspec, ref_nr);
 	free_refspec(ref_nr, refspec);
-	transport_disconnect(transport);
-	transport = NULL;
+	transport_disconnect(gtransport);
+	gtransport = NULL;
 	return exit_code;
 }
 
-- 
1.8.4-rc1-210-gf6d87e2
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 6 in “work around "transport-take-over" hack”
  1. 0/5 work around "transport-take-over" hackJunio C Hamano, Aug 7, 2013
  2. 1/5 t5802: add test for connect helperJunio C Hamano, Aug 7, 2013
  3. 2/5 fetch: rename file-scope global "transport" to "gtransport"Junio C Hamano, Aug 7, 2013
  4. 3/5 fetch: refactor code that prepares a transportJunio C Hamano, Aug 7, 2013
  5. 4/5 fetch: refactor code that fetches leftover tagsJunio C Hamano, Aug 7, 2013
  6. 5/5 fetch: work around "transport-take-over" hackJunio C Hamano, Aug 7, 2013

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.