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

[RFC 2/3] Alternates API: Improve naming

From
Michael Witten <mfwitten@gmail.com>
Date
Mar 30, 2011, 21:24 UTC
Message-ID
<a0e5204fe8c03b3b6af2150198bad51f86b126c4.1301521243.git.mfwitten@gmail.com>
In-Reply-To
<cover.1301521243.git.mfwitten@gmail.com>
This should make the API a bit more cohesive.
Signed-off-by: Michael Witten <mfwitten@gmail.com>
---
 builtin/fetch-pack.c   |    2 +-
 builtin/receive-pack.c |    2 +-
 sha1_file.c            |    6 +++---
 transport.c            |    8 ++++----
 transport.h            |    4 ++--
 5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/transport.h b/transport.h
index 72a692f..88fa484 100644
--- a/transport.h
+++ b/transport.h
@@ -166,7 +166,7 @@ int transport_refs_pushed(struct ref *ref);
 void transport_print_push_status(const char *dest, struct ref *refs,
 		  int verbose, int porcelain, int *nonfastforward);
 
-typedef void (*alternate_ref_fn)(const struct ref *, void *);
+typedef void (*transport_alt_refs_fn)(const struct ref *, void *);
-extern int refs_from_alternate_cb(struct alternate_object_database *, alternate_ref_fn);
+extern int transport_alt_refs(struct alternate_object_database *, transport_alt_refs_fn);
 
 #endif
diff --git a/transport.c b/transport.c
index c61723f..53d37a9 100644
--- a/transport.c
+++ b/transport.c
@@ -1190,7 +1190,7 @@ literal_copy:
 	return xstrdup(url);
 }
 
-int refs_from_alternate_cb(struct alternate_object_database *e, alternate_ref_fn ref_fn)
+int transport_alt_refs(struct alternate_object_database *d, transport_alt_refs_fn ref_fn)
 {
 	char *other;
 	size_t len;
@@ -1198,9 +1198,9 @@ int refs_from_alternate_cb(struct alternate_object_database *e, alternate_ref_fn
 	struct transport *transport;
 	const struct ref *extra;
 
-	e->name[-1] = '\0';
+	d->name[-1] = '\0';
-	other = xstrdup(real_path(e->base));
+	other = xstrdup(real_path(d->base));
-	e->name[-1] = '/';
+	d->name[-1] = '/';
 	len = strlen(other);
 
 	while (other[len-1] == '/')
diff --git a/sha1_file.c b/sha1_file.c
index e55a496..a6c1f1f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -390,11 +390,11 @@ void add_to_alternates_file(const char *reference)
 
 void foreach_alt_odb(alt_odb_fn fn)
 {
-	struct alternate_object_database *ent;
+	struct alternate_object_database *d;
 
 	prepare_alt_odb();
-	for (ent = alt_odb_list; ent; ent = ent->next)
+	for (d = alt_odb_list; d; d = d->next)
-		if (fn(ent))
+		if (fn(d))
 			return;
 }
 
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 62ebdb4..b3a9f74 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -226,7 +226,7 @@ static void insert_one_alternate_ref(const struct ref *ref, void *unused)
 
 static int alt_odb_callback(struct alternate_object_database *d)
 {
-	return refs_from_alternate_cb(d,insert_one_alternate_ref);
+	return transport_alt_refs(d,insert_one_alternate_ref);
 }
 
 static void insert_alternate_refs(void)
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 8ef6301..a761332 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -738,7 +738,7 @@ static void add_one_alternate_ref(const struct ref *ref, void *unused)
 
 static int alt_odb_callback(struct alternate_object_database *d)
 {
-	return refs_from_alternate_cb(d,add_one_alternate_ref);
+	return transport_alt_refs(d,add_one_alternate_ref);
 }
 
 static void add_alternate_refs(void)
-- 
1.7.4.18.g68fe8
Previous: Junio C HamanoNext: Junio C Hamano
Message 8 of 12 in “[RFC 1/2] Portability: Convert strictly between function pointers”
  1. Michael WittenMar 29, 2011
  2. 2/2 Future Proofing: Pass around pointers to either functions or dataMichael Witten, Mar 29, 2011
  3. Erik Faye-LundMar 30, 2011
  4. Michael WittenMar 30, 2011
  5. Junio C HamanoMar 30, 2011
  6. 1/3 Alternates API: Untangle the interfaceMichael Witten, Mar 30, 2011
  7. Junio C HamanoMar 30, 2011
  8. 2/3 Alternates API: Improve namingMichael Witten, Mar 30, 2011
  9. Junio C HamanoMar 30, 2011
  10. 3/3 Alternates API: Remove unused parameterMichael Witten, Mar 30, 2011
  11. 0/3 Alternates APIMichael Witten, Mar 30, 2011
  12. Junio C HamanoMar 30, 2011

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.