Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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 <peff@peff.net>
Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information...
commit 9c183a70722804114ac1dc54d17fe791ac1a452c 1 parent 6319a2a
Jeff King authored July 18, 2012 gitster committed July 18, 2012
12  Documentation/git-credential.txt
@@ -140,3 +140,15 @@ Git understands the following attributes:
140 140
 `password`::
141 141
 
142 142
 	The credential's password, if we are asking it to be stored.
  143
+
  144
+`url`::
  145
+
  146
+	When this special attribute is read by `git credential`, the
  147
+	value is parsed as a URL and treated as if its constituent parts
  148
+	were read (e.g., `url=https://example.com` would behave as if
  149
+	`protocol=https` and `host=example.com` had been provided). This
  150
+	can help callers avoid parsing URLs themselves.  Note that any
  151
+	components which are missing from the URL (e.g., there is no
  152
+	username in the example above) will be set to empty; if you want
  153
+	to provide a URL and override some attributes, provide the URL
  154
+	attribute first, followed by any overrides.
2  credential.c
@@ -172,6 +172,8 @@ int credential_read(struct credential *c, FILE *fp)
172 172
 		} else if (!strcmp(key, "path")) {
173 173
 			free(c->path);
174 174
 			c->path = xstrdup(value);
  175
+		} else if (!strcmp(key, "url")) {
  176
+			credential_from_url(c, value);
175 177
 		}
176 178
 		/*
177 179
 		 * Ignore other lines; we don't know what they mean, but

0 notes on commit 9c183a7

Please sign in to comment.
Something went wrong with that request. Please try again.