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

[RFCv2 02/12] Document details of transport function APIs

From
Johan Herland <johan@herland.net>
Date
Jul 31, 2009, 10:00 UTC
Message-ID
<1249034432-31437-3-git-send-email-johan@herland.net>
In-Reply-To
<1249034432-31437-1-git-send-email-johan@herland.net>
From: Daniel Barkalow <barkalow@iabervon.org>

In particular, explain which of the fields of struct ref is used for what purpose in the input to and output from each function.

Signed-off-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Johan Herland <johan@herland.net>
---
 transport.h |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
diff --git a/transport.h b/transport.h
index 3cb0abc..b45e6c5 100644
--- a/transport.h
+++ b/transport.h
@@ -18,11 +18,49 @@ struct transport {
 	int (*set_option)(struct transport *connection, const char *name,
 			  const char *value);
 
+	/**
+	 * Returns a list of the remote side's refs. In order to allow
+	 * the transport to try to share connections, for_push is a
+	 * hint as to whether the ultimate operation is a push or a fetch.
+	 *
+	 * If the transport is able to determine the remote hash for
+	 * the ref without a huge amount of effort, it should store it
+	 * in the ref's old_sha1 field; otherwise it should be all 0.
+	 **/
 	struct ref *(*get_refs_list)(struct transport *transport, int for_push);
+
+	/**
+	 * Fetch the objects for the given refs. Note that this gets
+	 * an array, and should ignore the list structure.
+	 *
+	 * If the transport did not get hashes for refs in
+	 * get_refs_list(), it should set the old_sha1 fields in the
+	 * provided refs now.
+	 **/
 	int (*fetch)(struct transport *transport, int refs_nr, struct ref **refs);
+
+	/**
+	 * Push the objects and refs. Send the necessary objects, and
+	 * then tell the remote side to update each ref in the list
+	 * from old_sha1 to new_sha1.
+	 *
+	 * Where possible, set the status for each ref appropriately.
+	 *
+	 * If, in the process, the transport determines that the
+	 * remote side actually responded to the push by updating the
+	 * ref to a different value, the transport should modify the
+	 * new_sha1 in the ref. (Note that this is a matter of the
+	 * remote accepting but rewriting the change, not rejecting it
+	 * and reporting that a different update had already taken
+	 * place)
+	 **/
 	int (*push_refs)(struct transport *transport, struct ref *refs, int flags);
 	int (*push)(struct transport *connection, int refspec_nr, const char **refspec, int flags);
 
+	/** get_refs_list(), fetch(), and push_refs() can keep
+	 * resources (such as a connection) reserved for futher
+	 * use. disconnect() releases these resources.
+	 **/
 	int (*disconnect)(struct transport *connection);
 	char *pack_lockfile;
 	signed verbose : 2;
-- 
1.6.4.rc3.138.ga6b98.dirty
Previous: Johan HerlandNext: Johan Herland
Message 3 of 12 in “[RFCv2 00/12] Foreign VCS helper program for CVS repositories”
  1. Johan HerlandJul 31, 2009
  2. 01/12 Allow late reporting of fetched hashesJohan Herland, Jul 31, 2009
  3. 02/12 Document details of transport function APIsJohan Herland, Jul 31, 2009
  4. 03/12 Add option for using a foreign VCSJohan Herland, Jul 31, 2009
  5. 04/12 Add specification of git-vcs-* helper programsJohan Herland, Jul 31, 2009
  6. 05/12 Use a function to determine whether a remote is validJohan Herland, Jul 31, 2009
  7. 06/12 Allow programs to not depend on remotes having urlsJohan Herland, Jul 31, 2009
  8. 07/12 Add a transport implementation using git-vcs-* helpersJohan Herland, Jul 31, 2009
  9. 08/12 Preliminary clarifications to git-vcs documentationJohan Herland, Jul 31, 2009
  10. 09/12 Teach foreign transport code to perform the "capabilities" commandJohan Herland, Jul 31, 2009
  11. 10/12 Introduce a 'marks <filename>' feature to the foreign transport codeJohan Herland, Jul 31, 2009
  12. 12/12 Add simple test cases of git-vcs-cvs functionalityJohan Herland, Jul 31, 2009

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.