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

[PATCH 2/4 v2] api-credential.txt: show the big picture first

From
Matthieu Moy <matthieu.moy@imag.fr>
Date
Jun 4, 2012, 20:17 UTC
Message-ID
<1338841064-32294-2-git-send-email-Matthieu.Moy@imag.fr>
In-Reply-To
<1338841064-32294-1-git-send-email-Matthieu.Moy@imag.fr>

The API documentation targets two kinds of developers: those using the (C) API, and those writing remote-helpers. The document was not clear about which part was useful to which category, and for example, the C API could be mistakenly thought as an API for writting remote helpers.

Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
Fixed typos noted by Jeff.
 Documentation/technical/api-credentials.txt | 50 +++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 3 deletions(-)
diff --git a/Documentation/technical/api-credentials.txt b/Documentation/technical/api-credentials.txt
index 21ca6a2..2d6e811 100644
--- a/Documentation/technical/api-credentials.txt
+++ b/Documentation/technical/api-credentials.txt
@@ -6,8 +6,52 @@ password credentials from the user (even though credentials in the wider
 world can take many forms, in this document the word "credential" always
 refers to a username and password pair).
 
+This document describes two interfaces: the C API that the credential
+subsystem provides to the rest of git, and the protocol that git uses to
+communicate with system-specific "credential helpers". If you are
+writing git code that wants to look up or prompt for credentials, see
+the section "C API" below. If you want to write your own helper, see
+the section on "Credential Helpers" below.
+
+Typical setup
+-------------
+
+------------
++-----------------------+
+| git code (C)          |--- to server requiring --->
+|                       |        authentication
+|.......................|
+| C credential API      |--- prompt ---> User
++-----------------------+
+        ^      |
+        | pipe |
+        |      v
++-----------------------+
+| git credential helper |
++-----------------------+
+------------
+
+The git code (typically a remote-helper) will call the C API to obtain
+credential data like a login/password pair (credential_fill). The
+API will itself call a remote helper (e.g. "git credential-cache" or
+"git credential-store") that may retrieve credential data from a
+store. If the credential helper cannot find the information, the C API
+will prompt the user. Then, the caller of the API takes care of
+contacting the server, and does the actual authentication.
+
+C API
+-----
+
+The credential C API is meant to be called by git code which needs to
+acquire or store a credential. It is centered around an object
+representing a single credential and provides three basic operations:
+fill (acquire credentials by calling helpers and/or prompting the user),
+approve (mark a credential as successfully used so that it can be stored
+for later use), and reject (mark a credential as unsuccessful so that it
+can be erased from any persistent storage).
+
 Data Structures
----------------
+~~~~~~~~~~~~~~~
 
 `struct credential`::
 
@@ -28,7 +72,7 @@ This struct should always be initialized with `CREDENTIAL_INIT` or
 
 
 Functions
----------
+~~~~~~~~~
 
 `credential_init`::
 
@@ -72,7 +116,7 @@ Functions
 	Parse a URL into broken-down credential fields.
 
 Example
--------
+~~~~~~~
 
 The example below shows how the functions of the credential API could be
 used to login to a fictitious "foo" service on a remote host:
-- 
1.7.11.rc0.57.g84a04c7
Previous: Matthieu MoyNext: Jeff King
Message 21 of 24 in “Improve credential API documentation”
  1. 0/3 Improve credential API documentationMatthieu Moy, Jun 3, 2012
  2. 1/3 api-credential.txt: show the big picture firstMatthieu Moy, Jun 3, 2012
  3. Jeff KingJun 4, 2012
  4. 2/3 api-credentials.txt: mention credential.helper explicitlyMatthieu Moy, Jun 3, 2012
  5. Jeff KingJun 4, 2012
  6. Matthieu MoyJun 4, 2012
  7. 3/3 api-credentials.txt: add "see also" sectionMatthieu Moy, Jun 3, 2012
  8. Junio C HamanoJun 3, 2012
  9. Matthieu MoyJun 4, 2012
  10. Jeff KingJun 4, 2012
  11. Junio C HamanoJun 4, 2012
  12. Matthieu MoyJun 4, 2012
  13. Jeff KingJun 5, 2012
  14. Jeff KingJun 5, 2012
  15. Matthieu MoyJun 5, 2012
  16. Jeff KingJun 5, 2012
  17. Junio C HamanoJun 5, 2012
  18. Jeff KingJun 5, 2012
  19. Junio C HamanoJun 5, 2012
  20. 1/4 doc: fix xref link from api docs to manual pagesMatthieu Moy, Jun 4, 2012
  21. 2/4 api-credential.txt: show the big picture firstMatthieu Moy, Jun 4, 2012
  22. Jeff KingJun 5, 2012
  23. 3/4 api-credentials.txt: mention credential.helper explicitlyMatthieu Moy, Jun 4, 2012
  24. 4/4 api-credentials.txt: add "see also" sectionMatthieu Moy, Jun 4, 2012

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.