From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth
Date: Mon, 23 Aug 2010 22:08:24 +1000 [thread overview]
Message-ID: <1282565304-3122-3-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <1282565304-3122-1-git-send-email-pclouds@gmail.com>
Users can do --depth=2147483648 for infinite depth now. It just looks
ugly. So make "0" special (i.e. infinite depth) at plumbing/protocol
level.
To make it even more user friendly, "git fetch" accepts --depth=inf as
an alternative to --depth=0. "git clone" also can. It just does not
make much sense for doing "git clone --depth=inf"
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Neither fetch-pack nor fetch uses parseopt, so Jonathan's OPT_INT_INF
has no use here (yet).
Documents updated.
Documentation/fetch-options.txt | 5 ++++-
Documentation/git-fetch-pack.txt | 1 +
Documentation/technical/shallow.txt | 2 ++
builtin/fetch-pack.c | 4 ++--
shallow.c | 2 +-
t/t5500-fetch-pack.sh | 8 ++++++++
upload-pack.c | 8 ++++----
7 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt
index 9333c42..0368afd 100644
--- a/Documentation/fetch-options.txt
+++ b/Documentation/fetch-options.txt
@@ -10,7 +10,10 @@
--depth=<depth>::
Deepen the history of a 'shallow' repository created by
`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])
- by the specified number of commits.
+ by the specified number of commits. Specify 0 or "inf"
+ for infinite depth, which may turn repository to a
+ non-shallow one again (you may need --tags so that all
+ commit chains are fully fetched).
ifndef::git-pull[]
--dry-run::
diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt
index 4a8487c..ce15196 100644
--- a/Documentation/git-fetch-pack.txt
+++ b/Documentation/git-fetch-pack.txt
@@ -70,6 +70,7 @@ OPTIONS
--depth=<n>::
Limit fetching to ancestor-chains not longer than n.
+ Specify 0 or "inf" for infinite depth.
--no-progress::
Do not show the progress.
diff --git a/Documentation/technical/shallow.txt b/Documentation/technical/shallow.txt
index 559263a..eeca540 100644
--- a/Documentation/technical/shallow.txt
+++ b/Documentation/technical/shallow.txt
@@ -47,3 +47,5 @@ It also writes an appropriate $GIT_DIR/shallow.
You can deepen a shallow repository with "git-fetch --depth 20
repo branch", which will fetch branch from repo, but stop at depth
20, updating $GIT_DIR/shallow.
+
+Depth 0 means infinite depth.
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 45d1824..df30381 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -844,8 +844,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
continue;
}
if (!prefixcmp(arg, "--depth=")) {
- args.depth = strtol(arg + 8, NULL, 0);
- if (args.depth <= 0)
+ args.depth = !strcmp(arg + 8, "inf") ? 0 : strtol(arg + 8, NULL, 0);
+ if (args.depth < 0)
die("Invalid depth %d", args.depth);
args.shallow = 1;
continue;
diff --git a/shallow.c b/shallow.c
index 4d90eda..eab97c6 100644
--- a/shallow.c
+++ b/shallow.c
@@ -85,7 +85,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
continue;
*pointer = cur_depth;
}
- if (cur_depth < depth) {
+ if (!depth || cur_depth < depth) {
if (p->next)
add_object_array(&p->item->object,
NULL, &stack);
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 18376d6..47fd87c 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -248,4 +248,12 @@ test_expect_success 'clone shallow object count' '
grep "^count: 52" count.shallow
'
+test_expect_success 'infinite deepening (full repo)' '
+ (
+ cd shallow &&
+ git fetch --depth=inf &&
+ ! test -f .git/shallow
+ )
+'
+
test_done
diff --git a/upload-pack.c b/upload-pack.c
index fc79dde..7b004b9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -484,7 +484,7 @@ static void receive_needs(void)
{
struct object_array shallows = {0, 0, NULL};
static char line[1000];
- int len, depth = 0;
+ int len, depth = -1;
shallow_nr = 0;
if (debug_fd)
@@ -514,7 +514,7 @@ static void receive_needs(void)
if (!prefixcmp(line, "deepen ")) {
char *end;
depth = strtol(line + 7, &end, 0);
- if (end == line + 7 || depth <= 0)
+ if (end == line + 7 || depth < 0)
die("Invalid deepen: %s", line);
continue;
}
@@ -562,9 +562,9 @@ static void receive_needs(void)
if (!use_sideband && daemon_mode)
no_progress = 1;
- if (depth == 0 && shallows.nr == 0)
+ if (depth == -1 && shallows.nr == 0)
return;
- if (depth > 0) {
+ if (depth >= 0) {
struct commit_list *result, *backup;
int i;
backup = result = get_shallow_commits(&want_obj, depth,
--
1.7.1.rc1.69.g24c2f7
next prev parent reply other threads:[~2010-08-23 22:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-23 12:08 [PATCH v2 1/3] clone: warn users --depth is ignored in local clones Nguyễn Thái Ngọc Duy
2010-08-23 12:08 ` [PATCH v2 2/3] fetch-pack: use args.shallow to detect shallow clone instead of args.depth Nguyễn Thái Ngọc Duy
2010-08-24 16:31 ` Junio C Hamano
2010-08-24 22:14 ` Nguyen Thai Ngoc Duy
2010-08-23 12:08 ` Nguyễn Thái Ngọc Duy [this message]
2010-08-24 13:53 ` [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth Jeff King
2010-08-24 17:39 ` Junio C Hamano
2010-08-24 17:46 ` Jeff King
2010-08-24 22:12 ` Nguyen Thai Ngoc Duy
2010-08-24 5:28 ` [PATCH v2 1/3] clone: warn users --depth is ignored in local clones Jonathan Nieder
2010-08-24 5:52 ` Nguyen Thai Ngoc Duy
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1282565304-3122-3-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).