credential: add function for parsing url components

All of the components of a credential struct can be found in
a URL.  For example, the URL:

  http://foo:bar@example.com/repo.git

contains:

  protocol=http
  host=example.com
  path=repo.git
  username=foo
  password=bar

We want to be able to turn URLs into broken-down credential
structs so that we know two things:

  1. Which parts of the username/password we still need

  2. What the context of the request is (for prompting or
     as a key for storing credentials).

This code is based on http_auth_init in http.c, but needed a
few modifications in order to get all of the components that
the credential object is interested in.

Once the http code is switched over to the credential API,
then http_auth_init can just go away.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
3 files changed
tree: 9c11a24464851c65cb020c3571887e28ae94c9f1
  1. block-sha1/
  2. builtin/
  3. compat/
  4. contrib/
  5. Documentation/
  6. git-gui/
  7. git_remote_helpers/
  8. gitk-git/
  9. gitweb/
  10. mergetools/
  11. perl/
  12. po/
  13. ppc/
  14. t/
  15. templates/
  16. vcs-svn/
  17. xdiff/
  18. .gitattributes
  19. .gitignore
  20. .mailmap
  21. abspath.c
  22. aclocal.m4
  23. advice.c
  24. advice.h
  25. alias.c
  26. alloc.c
  27. archive-tar.c
  28. archive-zip.c
  29. archive.c
  30. archive.h
  31. argv-array.c
  32. argv-array.h
  33. attr.c
  34. attr.h
  35. base85.c
  36. bisect.c
  37. bisect.h
  38. blob.c
  39. blob.h
  40. branch.c
  41. branch.h
  42. builtin.h
  43. bundle.c
  44. bundle.h
  45. cache-tree.c
  46. cache-tree.h
  47. cache.h
  48. check-builtins.sh
  49. check-racy.c
  50. check_bindir
  51. color.c
  52. color.h
  53. combine-diff.c
  54. command-list.txt
  55. commit.c
  56. commit.h
  57. config.c
  58. config.mak.in
  59. configure.ac
  60. connect.c
  61. connected.c
  62. connected.h
  63. convert.c
  64. convert.h
  65. copy.c
  66. COPYING
  67. credential.c
  68. credential.h
  69. csum-file.c
  70. csum-file.h
  71. ctype.c
  72. daemon.c
  73. date.c
  74. decorate.c
  75. decorate.h
  76. delta.h
  77. diff-delta.c
  78. diff-lib.c
  79. diff-no-index.c
  80. diff.c
  81. diff.h
  82. diffcore-break.c
  83. diffcore-delta.c
  84. diffcore-order.c
  85. diffcore-pickaxe.c
  86. diffcore-rename.c
  87. diffcore.h
  88. dir.c
  89. dir.h
  90. editor.c
  91. entry.c
  92. environment.c
  93. exec_cmd.c
  94. exec_cmd.h
  95. fast-import.c
  96. fetch-pack.h
  97. fixup-builtins
  98. fsck.c
  99. fsck.h
  100. generate-cmdlist.sh
  101. gettext.c
  102. gettext.h
  103. git-add--interactive.perl
  104. git-am.sh
  105. git-archimport.perl
  106. git-bisect.sh
  107. git-compat-util.h
  108. git-cvsexportcommit.perl
  109. git-cvsimport.perl
  110. git-cvsserver.perl
  111. git-difftool--helper.sh
  112. git-difftool.perl
  113. git-filter-branch.sh
  114. git-instaweb.sh
  115. git-lost-found.sh
  116. git-merge-octopus.sh
  117. git-merge-one-file.sh
  118. git-merge-resolve.sh
  119. git-mergetool--lib.sh
  120. git-mergetool.sh
  121. git-parse-remote.sh
  122. git-pull.sh
  123. git-quiltimport.sh
  124. git-rebase--am.sh
  125. git-rebase--interactive.sh
  126. git-rebase--merge.sh
  127. git-rebase.sh
  128. git-relink.perl
  129. git-remote-testgit.py
  130. git-repack.sh
  131. git-request-pull.sh
  132. git-send-email.perl
  133. git-sh-i18n.sh
  134. git-sh-setup.sh
  135. git-stash.sh
  136. git-submodule.sh
  137. git-svn.perl
  138. GIT-VERSION-GEN
  139. git-web--browse.sh
  140. git.c
  141. git.spec.in
  142. graph.c
  143. graph.h
  144. grep.c
  145. grep.h
  146. hash.c
  147. hash.h
  148. help.c
  149. help.h
  150. hex.c
  151. http-backend.c
  152. http-fetch.c
  153. http-push.c
  154. http-walker.c
  155. http.c
  156. http.h
  157. ident.c
  158. imap-send.c
  159. INSTALL
  160. kwset.c
  161. kwset.h
  162. levenshtein.c
  163. levenshtein.h
  164. LGPL-2.1
  165. list-objects.c
  166. list-objects.h
  167. ll-merge.c
  168. ll-merge.h
  169. lockfile.c
  170. log-tree.c
  171. log-tree.h
  172. mailmap.c
  173. mailmap.h
  174. Makefile
  175. match-trees.c
  176. merge-file.c
  177. merge-file.h
  178. merge-recursive.c
  179. merge-recursive.h
  180. name-hash.c
  181. notes-cache.c
  182. notes-cache.h
  183. notes-merge.c
  184. notes-merge.h
  185. notes.c
  186. notes.h
  187. object.c
  188. object.h
  189. pack-check.c
  190. pack-refs.c
  191. pack-refs.h
  192. pack-revindex.c
  193. pack-revindex.h
  194. pack-write.c
  195. pack.h
  196. pager.c
  197. parse-options-cb.c
  198. parse-options.c
  199. parse-options.h
  200. patch-delta.c
  201. patch-ids.c
  202. patch-ids.h
  203. path.c
  204. pkt-line.c
  205. pkt-line.h
  206. preload-index.c
  207. pretty.c
  208. progress.c
  209. progress.h
  210. quote.c
  211. quote.h
  212. reachable.c
  213. reachable.h
  214. read-cache.c
  215. README
  216. reflog-walk.c
  217. reflog-walk.h
  218. refs.c
  219. refs.h
  220. remote-curl.c
  221. remote.c
  222. remote.h
  223. replace_object.c
  224. rerere.c
  225. rerere.h
  226. resolve-undo.c
  227. resolve-undo.h
  228. revision.c
  229. revision.h
  230. run-command.c
  231. run-command.h
  232. send-pack.h
  233. sequencer.c
  234. sequencer.h
  235. server-info.c
  236. setup.c
  237. sh-i18n--envsubst.c
  238. sha1-array.c
  239. sha1-array.h
  240. sha1-lookup.c
  241. sha1-lookup.h
  242. sha1_file.c
  243. sha1_name.c
  244. shallow.c
  245. shell.c
  246. shortlog.h
  247. show-index.c
  248. sideband.c
  249. sideband.h
  250. sigchain.c
  251. sigchain.h
  252. strbuf.c
  253. strbuf.h
  254. streaming.c
  255. streaming.h
  256. string-list.c
  257. string-list.h
  258. submodule.c
  259. submodule.h
  260. symlinks.c
  261. tag.c
  262. tag.h
  263. tar.h
  264. test-chmtime.c
  265. test-credential.c
  266. test-ctype.c
  267. test-date.c
  268. test-delta.c
  269. test-dump-cache-tree.c
  270. test-genrandom.c
  271. test-index-version.c
  272. test-line-buffer.c
  273. test-match-trees.c
  274. test-mktemp.c
  275. test-obj-pool.c
  276. test-parse-options.c
  277. test-path-utils.c
  278. test-run-command.c
  279. test-sha1.c
  280. test-sha1.sh
  281. test-sigchain.c
  282. test-string-pool.c
  283. test-subprocess.c
  284. test-svn-fe.c
  285. test-treap.c
  286. thread-utils.c
  287. thread-utils.h
  288. trace.c
  289. transport-helper.c
  290. transport.c
  291. transport.h
  292. tree-diff.c
  293. tree-walk.c
  294. tree-walk.h
  295. tree.c
  296. tree.h
  297. unimplemented.sh
  298. unpack-trees.c
  299. unpack-trees.h
  300. upload-pack.c
  301. url.c
  302. url.h
  303. usage.c
  304. userdiff.c
  305. userdiff.h
  306. utf8.c
  307. utf8.h
  308. walker.c
  309. walker.h
  310. wrap-for-bin.sh
  311. wrapper.c
  312. write_or_die.c
  313. ws.c
  314. wt-status.c
  315. wt-status.h
  316. xdiff-interface.c
  317. xdiff-interface.h
  318. zlib.c