Browse files

credential: convert "url" attribute into its parsed subparts

The git-credential command requires that you feed it a
broken-down credential, which means that the client needs to
parse a URL itself. Since we have our own URL-parsing
routines, we can easily allow the caller to just give us the
URL as-is, saving them some code.

Signed-off-by: Jeff King <>
Acked-by: Matthieu Moy <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
1 parent 6319a2a commit 9c183a70722804114ac1dc54d17fe791ac1a452c @peff peff committed with gitster Jul 18, 2012
Showing with 14 additions and 0 deletions.
  1. +12 −0 Documentation/git-credential.txt
  2. +2 −0 credential.c
@@ -140,3 +140,15 @@ Git understands the following attributes:
The credential's password, if we are asking it to be stored.
+ When this special attribute is read by `git credential`, the
+ value is parsed as a URL and treated as if its constituent parts
+ were read (e.g., `url=` would behave as if
+ `protocol=https` and `` had been provided). This
+ can help callers avoid parsing URLs themselves. Note that any
+ components which are missing from the URL (e.g., there is no
+ username in the example above) will be set to empty; if you want
+ to provide a URL and override some attributes, provide the URL
+ attribute first, followed by any overrides.
@@ -172,6 +172,8 @@ int credential_read(struct credential *c, FILE *fp)
} else if (!strcmp(key, "path")) {
c->path = xstrdup(value);
+ } else if (!strcmp(key, "url")) {
+ credential_from_url(c, value);
* Ignore other lines; we don't know what they mean, but

0 comments on commit 9c183a7

Please sign in to comment.