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

[PATCH v3 0/5] Bundle URIs II: git clone --bundle-uri

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 9, 2022, 13:11 UTC
Message-ID
<pull.1300.v3.git.1660050703.gitgitgadget@gmail.com>
In-Reply-To
<pull.1300.v2.git.1659443384.gitgitgadget@gmail.com>

This is the second series building the bundle URI feature as discussed in the previous series that added the design document [1]. This series does not modify the design document, so the patches are independent and can be applied to the latest 'master'.

[1] https://lore.kernel.org/git/pull.1248.v3.git.1658757188.gitgitgadget@gmail.com

This series brings in just enough logic that we can bootstrap clones from a single bundle using git clone --bundle-uri=<X>.

 * Patch 1 adds a 'get' capability to 'git remote-https' which allows
   downloading the contents of a URI to a local file.
 * Patch 2 creates basic file-copy logic within a new bundle-uri.c file. It
   is not used until patch 3.
 * Patch 3 creates the git clone --bundle-uri=<X> option, allowing Git to
   bootstrap a clone from a bundle, but get the remaining objects from the
   origin URL. (As of this patch, it only accepts a filename.)
 * Patch 4 extends the git clone --bundle-uri=<X> option to allow file://
   and https:// URIs.
 * Patch 5 is a CLI helper to avoid using --bundle-uri and --depth at the
   same time in git clone.
As outlined in [1], the next steps after this are:
 1. Allow parsing a bundle list as a config file at the given URI. The
    key-value format is unified with the protocol v2 verb (coming in (3)).
    [2]
 2. Implement the protocol v2 verb, re-using the bundle list logic from (2).
    Use this to auto-discover bundle URIs during 'git clone' (behind a
    config option). [3]
 3. Implement the 'creationToken' heuristic, allowing incremental 'git
    fetch' commands to download a bundle list from a configured URI, and
    only download bundles that are new based on the creation token values.
    [4]

I have prepared some of this work as pull requests on my personal fork so curious readers can look ahead to where we are going:

[2] https://github.com/derrickstolee/git/pull/20
[3] https://github.com/derrickstolee/git/pull/21
[4] https://github.com/derrickstolee/git/pull/22
Note: this series includes some code pulled out of the first series [1], and
in particular the git fetch --bundle-uri=<X> option is removed. The
intention was to replace that with git bundle fetch <X>, but that conflicts
with the work to refactor how subcommands are parsed. The git bundle fetch
subcommand could be added later for maximum flexibility on the client side,
but we can also move forward without it.

Updates in v3 =============

 * The protocol matching for "http://", "https://", and "file://" now
   uniformly include the "//" portion and are case-sensitive.

Updates in v2 =============

 * Several typos or small tweaks. See the range-diff for details.
Thanks, -Stolee
Derrick Stolee (5):
  remote-curl: add 'get' capability
  bundle-uri: create basic file-copy logic
  clone: add --bundle-uri option
  bundle-uri: add support for http(s):// and file://
  clone: --bundle-uri cannot be combined with --depth
 Documentation/git-clone.txt         |   7 ++
 Documentation/gitremote-helpers.txt |   9 ++
 Makefile                            |   1 +
 builtin/clone.c                     |  18 +++
 bundle-uri.c                        | 168 ++++++++++++++++++++++++++++
 bundle-uri.h                        |  14 +++
 remote-curl.c                       |  28 +++++
 t/t5557-http-get.sh                 |  39 +++++++
 t/t5558-clone-bundle-uri.sh         |  81 ++++++++++++++
 t/t5606-clone-options.sh            |   8 ++
 10 files changed, 373 insertions(+)
 create mode 100644 bundle-uri.c
 create mode 100644 bundle-uri.h
 create mode 100755 t/t5557-http-get.sh
 create mode 100755 t/t5558-clone-bundle-uri.sh
base-commit: e72d93e88cb20b06e88e6e7d81bd1dc4effe453f
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1300%2Fderrickstolee%2Fbundle-redo%2Fclone-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1300/derrickstolee/bundle-redo/clone-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1300
Range-diff vs v2:
 1:  4df4a1d679a = 1:  4df4a1d679a remote-curl: add 'get' capability
 2:  6a6f1a04889 = 2:  6a6f1a04889 bundle-uri: create basic file-copy logic
 3:  00debaf6e77 = 3:  00debaf6e77 clone: add --bundle-uri option
 4:  e4f2dcc7a45 ! 4:  66a1ce40451 bundle-uri: add support for http(s):// and file://
     @@ bundle-uri.c: static int find_temp_filename(struct strbuf *name)
      +	struct strbuf line = STRBUF_INIT;
      +	int found_get = 0;
      +
     -+	strvec_pushl(&cp.args, "git-remote-https", "origin", uri, NULL);
     ++	strvec_pushl(&cp.args, "git-remote-https", uri, NULL);
      +	cp.in = -1;
      +	cp.out = -1;
      +
     @@ bundle-uri.c: static int find_temp_filename(struct strbuf *name)
      +{
      +	const char *out;
      +
     -+	if (istarts_with(uri, "https:") ||
     -+	    istarts_with(uri, "http:"))
     ++	if (starts_with(uri, "https:") ||
     ++	    starts_with(uri, "http:"))
      +		return download_https_uri_to_file(filename, uri);
      +
     -+	if (!skip_prefix(uri, "file://", &out))
     -+		out = uri;
     ++	if (skip_prefix(uri, "file://", &out))
     ++		uri = out;
      +
      +	/* Copy as a file */
     -+	return copy_file(filename, out, 0);
     ++	return copy_file(filename, uri, 0);
       }
       
       static int unbundle_from_file(struct repository *r, const char *file)
 5:  acee1fae027 = 5:  ed76d84c5a7 clone: --bundle-uri cannot be combined with --depth
-- 
gitgitgadget
Previous: Derrick Stolee via GitGitGadgetNext: Derrick Stolee via GitGitGadget
Message 26 of 36 in “Bundle URIs II: git clone --bundle-uri”
  1. 0/5 Bundle URIs II: git clone --bundle-uriDerrick Stolee via GitGitGadget, Jul 25, 2022
  2. 1/5 remote-curl: add 'get' capabilityDerrick Stolee via GitGitGadget, Jul 25, 2022
  3. Josh SteadmonJul 27, 2022
  4. Ævar Arnfjörð BjarmasonJul 27, 2022
  5. Derrick StoleeAug 1, 2022
  6. Ævar Arnfjörð BjarmasonAug 1, 2022
  7. 2/5 bundle-uri: create basic file-copy logicDerrick Stolee via GitGitGadget, Jul 25, 2022
  8. Josh SteadmonJul 27, 2022
  9. Derrick StoleeAug 1, 2022
  10. 3/5 clone: add --bundle-uri optionDerrick Stolee via GitGitGadget, Jul 25, 2022
  11. 5/5 clone: --bundle-uri cannot be combined with --depthDerrick Stolee via GitGitGadget, Jul 25, 2022
  12. 4/5 bundle-uri: add support for http(s):// and file://Derrick Stolee via GitGitGadget, Jul 25, 2022
  13. Josh SteadmonJul 27, 2022
  14. Derrick StoleeAug 1, 2022
  15. Josh SteadmonJul 27, 2022
  16. Derrick StoleeAug 1, 2022
  17. 0/5 Bundle URIs II: git clone --bundle-uriDerrick Stolee via GitGitGadget, Aug 2, 2022
  18. 1/5 remote-curl: add 'get' capabilityDerrick Stolee via GitGitGadget, Aug 2, 2022
  19. 2/5 bundle-uri: create basic file-copy logicDerrick Stolee via GitGitGadget, Aug 2, 2022
  20. 3/5 clone: add --bundle-uri optionDerrick Stolee via GitGitGadget, Aug 2, 2022
  21. 4/5 bundle-uri: add support for http(s):// and file://Derrick Stolee via GitGitGadget, Aug 2, 2022
  22. Junio C HamanoAug 2, 2022
  23. Derrick StoleeAug 4, 2022
  24. Junio C HamanoAug 4, 2022
  25. 5/5 clone: --bundle-uri cannot be combined with --depthDerrick Stolee via GitGitGadget, Aug 2, 2022
  26. 0/5 Bundle URIs II: git clone --bundle-uriDerrick Stolee via GitGitGadget, Aug 9, 2022
  27. 1/5 remote-curl: add 'get' capabilityDerrick Stolee via GitGitGadget, Aug 9, 2022
  28. 2/5 bundle-uri: create basic file-copy logicDerrick Stolee via GitGitGadget, Aug 9, 2022
  29. 3/5 clone: add --bundle-uri optionDerrick Stolee via GitGitGadget, Aug 9, 2022
  30. Junio C HamanoAug 22, 2022
  31. Derrick StoleeAug 23, 2022
  32. Junio C HamanoAug 24, 2022
  33. 4/5 bundle-uri: add support for http(s):// and file://Derrick Stolee via GitGitGadget, Aug 9, 2022
  34. 4/5 bundle-uri: add support for http(s):// and file://Teng Long, Aug 29, 2022
  35. Derrick StoleeAug 30, 2022
  36. 5/5 clone: --bundle-uri cannot be combined with --depthDerrick Stolee via GitGitGadget, Aug 9, 2022

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.