From: Eric Sunshine <sunshine@sunshineco.com>
To: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Cc: Git List <git@vger.kernel.org>, Dongcan Jiang <dongcan.jiang@gmail.com>
Subject: Re: [PATCH 20/20] fetch: add --deepen=<N> to extend shallow boundary by <N> commits
Date: Mon, 4 Jan 2016 04:45:05 -0500 [thread overview]
Message-ID: <CAPig+cTiN+y0KXLjoK0EeyxXk6DOMG16A2gQ_a9PsU__DA-LUg@mail.gmail.com> (raw)
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:
> 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.
> 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/ ?
> 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);
?
> + }
> 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.
> + )
> +'
next prev parent reply other threads:[~2016-01-04 9:45 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-29 12:10 [PATCH 00/20] More flexibility in making shallow clones Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 01/20] upload-pack: move shallow deepen code out of receive_needs() Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 02/20] upload-pack: move "shallow" sending code out of deepen() Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 03/20] upload-pack: remove unused variable "backup" Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 04/20] upload-pack: move "unshallow" sending code out of deepen() Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 05/20] shallow.c: implement a generic shallow boundary finder based on rev-list Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 06/20] upload-pack: glue code to use get_shallow_commits_by_rev_list Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 07/20] upload-pack: use skip_prefix() instead of starts_with() when possible Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 08/20] upload-pack: tighten number parsing at "deepen" lines Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 09/20] upload-pack: add deepen-since to cut shallow repos based on time Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 10/20] fetch-pack: use a common function for verbose printing Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 11/20] fetch-pack: use a separate flag for fetch in deepening mode Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 12/20] fetch: define shallow boundary with --since Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 13/20] clone: define shallow clone boundary based on time " Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 14/20] Add test_repo_expect_success for running tests in a new repository Nguyễn Thái Ngọc Duy
2015-12-29 14:12 ` Duy Nguyen
2015-12-29 12:10 ` [PATCH 15/20] t5500: test for shallow depth since a specific date Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 16/20] upload-pack: support define shallow boundary by excluding revisions Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 17/20] fetch: define shallow boundary with --not Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 18/20] clone: define shallow clone " Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 19/20] t5500: test for shallow depth excluding a ref Nguyễn Thái Ngọc Duy
2015-12-29 12:10 ` [PATCH 20/20] fetch: add --deepen=<N> to extend shallow boundary by <N> commits Nguyễn Thái Ngọc Duy
2016-01-04 9:45 ` Eric Sunshine [this message]
2015-12-29 19:09 ` [PATCH 00/20] More flexibility in making shallow clones Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPig+cTiN+y0KXLjoK0EeyxXk6DOMG16A2gQ_a9PsU__DA-LUg@mail.gmail.com \
--to=sunshine@sunshineco.com \
--cc=dongcan.jiang@gmail.com \
--cc=git@vger.kernel.org \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).