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

Re: [PATCH 20/20] fetch: add --deepen=<N> to extend shallow boundary by <N> commits

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jan 4, 2016, 09:45 UTC
Message-ID
<CAPig+cTiN+y0KXLjoK0EeyxXk6DOMG16A2gQ_a9PsU__DA-LUg@mail.gmail.com>
In-Reply-To
<1451391043-28093-21-git-send-email-pclouds@gmail.com>
On Tue, Dec 29, 2015 at 7:10 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 12 quoted lines
> In git-fetch, --depth argument is always relative with the latest
> remote refs. This makes it a bit difficult to cover this use case,
> where the user wants to make the shallow history, say 3 levels
> deeper. It would work if remote refs have not moved yet, but nobody
> can guarantee that, especially when that use case is performed a
> couple months after the last clone or "git fetch --depth". Also,
> modifying shallow boundary using --depth does not work well with
> clones created by --since or --not.
> [...]
>
> Helped-by: Duy Nguyen <pclouds@gmail.com>
> Helped-By: Eric Sunshine <sunshine@sunshineco.com>
s/By/by/
> Helped-By: Junio C Hamano <gitster@pobox.com>
Ditto.
Show 9 quoted lines
> Signed-off-by: Dongcan Jiang <dongcan.jiang@gmail.com>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
> @@ -13,6 +13,11 @@
> +--deepen=<depth>::
> +       Similar to --depth, except it specifies the number of commits
> +       from the current shallow boundary instead of from the tip of
> +       reach remote branch history.
Did you mean s/reach/each/ ?
Show 13 quoted lines
> diff --git a/builtin/fetch.c b/builtin/fetch.c
> @@ -1185,6 +1189,15 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
>         /* no need to be strict, transport_set_option() will validate it again */
>         if (depth && atoi(depth) < 1)
>                 die(_("depth %s is not a positive number"), depth);
> +       if (deepen_relative) {
> +               struct strbuf sb = STRBUF_INIT;
> +               if (deepen_relative < 0)
> +                       die(_("Negative depth in --deepen is not supported"));
> +               if (depth)
> +                       die(_("--deepen and --depth are mutually exclusive"));
> +               strbuf_addf(&sb, "%d", deepen_relative);
> +               depth = strbuf_detach(&sb, NULL);
Maybe replace:
    struct strbuf sb = STRBUF_INIT;
    ...
    strbuf_addf(&sb, "%d", deepen_relative);
    depth = strbuf_detach(&sb, NULL);
with:
    depth = xstrfmt("%d", deepen_relative);
?
Show 7 quoted lines
> +       }
>         if (depth || deepen_since || deepen_not.nr)
>                 deepen = 1;
> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
> @@ -708,4 +708,16 @@ test_expect_success 'fetching a one-level ref works' '
> +test_expect_success 'fetching deepen' '
> +       git clone . deepen --depth=1 && (
Style: ( on its own line.
> +               cd deepen &&
> +               git fetch .. foo --depth=1
> +               git show foo

Are these git-show instances merely for checking if a ref is valid? If so, perhaps git-rev-parse would be clearer?

> +               test_must_fail git show foo~
> +               git fetch .. foo --deepen=1
> +               git show foo~
> +               test_must_fail git show foo~2
&&-chain heavily broken in subshell.
> +       )
> +'
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 23 of 24 in “More flexibility in making shallow clones”
  1. 00/20 More flexibility in making shallow clonesNguyễn Thái Ngọc Duy, Dec 29, 2015
  2. 01/20 upload-pack: move shallow deepen code out of receive_needs()Nguyễn Thái Ngọc Duy, Dec 29, 2015
  3. 02/20 upload-pack: move "shallow" sending code out of deepen()Nguyễn Thái Ngọc Duy, Dec 29, 2015
  4. 03/20 upload-pack: remove unused variable "backup"Nguyễn Thái Ngọc Duy, Dec 29, 2015
  5. 04/20 upload-pack: move "unshallow" sending code out of deepen()Nguyễn Thái Ngọc Duy, Dec 29, 2015
  6. 05/20 shallow.c: implement a generic shallow boundary finder based on rev-listNguyễn Thái Ngọc Duy, Dec 29, 2015
  7. 06/20 upload-pack: glue code to use get_shallow_commits_by_rev_listNguyễn Thái Ngọc Duy, Dec 29, 2015
  8. 07/20 upload-pack: use skip_prefix() instead of starts_with() when possibleNguyễn Thái Ngọc Duy, Dec 29, 2015
  9. 08/20 upload-pack: tighten number parsing at "deepen" linesNguyễn Thái Ngọc Duy, Dec 29, 2015
  10. 09/20 upload-pack: add deepen-since to cut shallow repos based on timeNguyễn Thái Ngọc Duy, Dec 29, 2015
  11. 10/20 fetch-pack: use a common function for verbose printingNguyễn Thái Ngọc Duy, Dec 29, 2015
  12. 11/20 fetch-pack: use a separate flag for fetch in deepening modeNguyễn Thái Ngọc Duy, Dec 29, 2015
  13. 12/20 fetch: define shallow boundary with --sinceNguyễn Thái Ngọc Duy, Dec 29, 2015
  14. 13/20 clone: define shallow clone boundary based on time with --sinceNguyễn Thái Ngọc Duy, Dec 29, 2015
  15. 14/20 Add test_repo_expect_success for running tests in a new repositoryNguyễn Thái Ngọc Duy, Dec 29, 2015
  16. Duy NguyenDec 29, 2015
  17. 15/20 t5500: test for shallow depth since a specific dateNguyễn Thái Ngọc Duy, Dec 29, 2015
  18. 16/20 upload-pack: support define shallow boundary by excluding revisionsNguyễn Thái Ngọc Duy, Dec 29, 2015
  19. 17/20 fetch: define shallow boundary with --notNguyễn Thái Ngọc Duy, Dec 29, 2015
  20. 18/20 clone: define shallow clone boundary with --notNguyễn Thái Ngọc Duy, Dec 29, 2015
  21. 19/20 t5500: test for shallow depth excluding a refNguyễn Thái Ngọc Duy, Dec 29, 2015
  22. 20/20 fetch: add --deepen=<N> to extend shallow boundary by <N> commitsNguyễn Thái Ngọc Duy, Dec 29, 2015
  23. Eric SunshineJan 4, 2016
  24. Junio C HamanoDec 29, 2015

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.