{"thread":{"id":"24842","subject":"[PATCH v2 2/3] fetch-pack: use args.shallow to detect shallow clone instead of args.depth","startedAt":"2010-08-23T12:08:22Z","lastAt":"2010-08-24T22:14:20Z","messageCount":11,"participants":["Nguyễn Thái Ngọc Duy","Jonathan Nieder","Nguyen Thai Ngoc Duy","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":3},"messages":[{"id":"148793","messageId":"1282565304-3122-1-git-send-email-pclouds@gmail.com","threadId":"24842","inReplyTo":null,"subject":"[PATCH v2 1/3] clone: warn users --depth is ignored in local clones","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-23T12:08:22Z","receivedAt":"2010-08-23T12:08:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Just warn users instead of dying in the old patch.\n\n builtin/clone.c |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex efb1e6f..fcdb039 100644\n--- a/builtin/clone.c\n+++ b/builtin/clone.c\n@@ -361,7 +361,7 @@ static void write_remote_refs(const struct ref *local_refs)\n \n int cmd_clone(int argc, const char **argv, const char *prefix)\n {\n-\tint is_bundle = 0;\n+\tint is_bundle = 0, is_local;\n \tstruct stat buf;\n \tconst char *repo_name, *repo, *work_tree, *git_dir;\n \tchar *path, *dir;\n@@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \t\trepo = xstrdup(make_absolute_path(repo_name));\n \telse\n \t\trepo = repo_name;\n+\tis_local = path && !is_bundle;\n+\tif (is_local && option_depth)\n+\t\twarning(\"--depth is ignored in local clones, use file:// instead.\");\n \n \tif (argc == 2)\n \t\tdir = xstrdup(argv[1]);\n@@ -514,7 +517,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n \n \tstrbuf_reset(&value);\n \n-\tif (path && !is_bundle) {\n+\tif (is_local) {\n \t\trefs = clone_local(path, git_dir);\n \t\tmapped_refs = wanted_peer_refs(refs, refspec);\n \t} else {\n-- \n1.7.1.rc1.69.g24c2f7\n"},{"id":"148792","messageId":"1282565304-3122-2-git-send-email-pclouds@gmail.com","threadId":"24842","inReplyTo":"1282565304-3122-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 2/3] fetch-pack: use args.shallow to detect shallow clone instead of args.depth","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-23T12:08:23Z","receivedAt":"2010-08-23T12:08:23Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n builtin/fetch-pack.c |   17 ++++++++++-------\n fetch-pack.h         |    3 ++-\n transport.c          |    9 +++++++--\n transport.h          |    1 +\n 4 files changed, 20 insertions(+), 10 deletions(-)\n\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex dbd8b7b..45d1824 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -167,7 +167,7 @@ enum ack_type {\n \n static void consume_shallow_list(int fd)\n {\n-\tif (args.stateless_rpc && args.depth > 0) {\n+\tif (args.stateless_rpc && args.shallow) {\n \t\t/* If we sent a depth we will get back \"duplicate\"\n \t\t * shallow and unshallow commands every time there\n \t\t * is a block of have lines exchanged.\n@@ -283,12 +283,12 @@ static int find_common(int fd[2], unsigned char *result_sha1,\n \n \tif (is_repository_shallow())\n \t\twrite_shallow_commits(&req_buf, 1);\n-\tif (args.depth > 0)\n+\tif (args.shallow)\n \t\tpacket_buf_write(&req_buf, \"deepen %d\", args.depth);\n \tpacket_buf_flush(&req_buf);\n \tstate_len = req_buf.len;\n \n-\tif (args.depth > 0) {\n+\tif (args.shallow) {\n \t\tchar line[1024];\n \t\tunsigned char sha1[20];\n \n@@ -476,7 +476,7 @@ static void filter_refs(struct ref **refs, int nr_match, char **match)\n \t\t    check_ref_format(ref->name + 5))\n \t\t\t; /* trash */\n \t\telse if (args.fetch_all &&\n-\t\t\t (!args.depth || prefixcmp(ref->name, \"refs/tags/\") )) {\n+\t\t\t (!args.shallow || prefixcmp(ref->name, \"refs/tags/\") )) {\n \t\t\t*newtail = ref;\n \t\t\tref->next = NULL;\n \t\t\tnewtail = &ref->next;\n@@ -534,7 +534,7 @@ static int everything_local(struct ref **refs, int nr_match, char **match)\n \t\t}\n \t}\n \n-\tif (!args.depth) {\n+\tif (!args.shallow) {\n \t\tfor_each_ref(mark_complete, NULL);\n \t\tif (cutoff)\n \t\t\tmark_recent_complete_commits(cutoff);\n@@ -845,6 +845,9 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \t\t\t}\n \t\t\tif (!prefixcmp(arg, \"--depth=\")) {\n \t\t\t\targs.depth = strtol(arg + 8, NULL, 0);\n+\t\t\t\tif (args.depth <= 0)\n+\t\t\t\t\tdie(\"Invalid depth %d\", args.depth);\n+\t\t\t\targs.shallow = 1;\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!strcmp(\"--no-progress\", arg)) {\n@@ -928,7 +931,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,\n \tfetch_pack_setup();\n \tif (&args != my_args)\n \t\tmemcpy(&args, my_args, sizeof(args));\n-\tif (args.depth > 0) {\n+\tif (args.shallow) {\n \t\tif (stat(git_path(\"shallow\"), &st))\n \t\t\tst.st_mtime = 0;\n \t}\n@@ -941,7 +944,7 @@ struct ref *fetch_pack(struct fetch_pack_args *my_args,\n \t}\n \tref_cpy = do_fetch_pack(fd, ref, nr_heads, heads, pack_lockfile);\n \n-\tif (args.depth > 0) {\n+\tif (args.shallow) {\n \t\tstruct cache_time mtime;\n \t\tstruct strbuf sb = STRBUF_INIT;\n \t\tchar *shallow = git_path(\"shallow\");\ndiff --git a/fetch-pack.h b/fetch-pack.h\nindex fbe85ac..abc1ab7 100644\n--- a/fetch-pack.h\n+++ b/fetch-pack.h\n@@ -14,7 +14,8 @@ struct fetch_pack_args\n \t\tverbose:1,\n \t\tno_progress:1,\n \t\tinclude_tag:1,\n-\t\tstateless_rpc:1;\n+\t\tstateless_rpc:1,\n+\t\tshallow:1;\n };\n \n struct ref *fetch_pack(struct fetch_pack_args *args,\ndiff --git a/transport.c b/transport.c\nindex 4dba6f8..cf7030b 100644\n--- a/transport.c\n+++ b/transport.c\n@@ -470,10 +470,14 @@ static int set_git_option(struct git_transport_options *opts,\n \t\topts->keep = !!value;\n \t\treturn 0;\n \t} else if (!strcmp(name, TRANS_OPT_DEPTH)) {\n-\t\tif (!value)\n+\t\tif (!value) {\n \t\t\topts->depth = 0;\n-\t\telse\n+\t\t\topts->shallow = 0;\n+\t\t}\n+\t\telse {\n \t\t\topts->depth = atoi(value);\n+\t\t\topts->shallow = 1;\n+\t\t}\n \t\treturn 0;\n \t}\n \treturn 1;\n@@ -529,6 +533,7 @@ static int fetch_refs_via_pack(struct transport *transport,\n \targs.quiet = (transport->verbose < 0);\n \targs.no_progress = !transport->progress;\n \targs.depth = data->options.depth;\n+\targs.shallow = data->options.shallow;\n \n \tfor (i = 0; i < nr_heads; i++)\n \t\torigh[i] = heads[i] = xstrdup(to_fetch[i]->name);\ndiff --git a/transport.h b/transport.h\nindex c59d973..e6ac4b1 100644\n--- a/transport.h\n+++ b/transport.h\n@@ -8,6 +8,7 @@ struct git_transport_options {\n \tunsigned thin : 1;\n \tunsigned keep : 1;\n \tunsigned followtags : 1;\n+\tunsigned shallow : 1;\n \tint depth;\n \tconst char *uploadpack;\n \tconst char *receivepack;\n-- \n1.7.1.rc1.69.g24c2f7\n"},{"id":"148794","messageId":"1282565304-3122-3-git-send-email-pclouds@gmail.com","threadId":"24842","inReplyTo":"1282565304-3122-1-git-send-email-pclouds@gmail.com","subject":"[PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-23T12:08:24Z","receivedAt":"2010-08-23T12:08:24Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"Users can do --depth=2147483648 for infinite depth now. It just looks\nugly. So make \"0\" special (i.e. infinite depth) at plumbing/protocol\nlevel.\n\nTo make it even more user friendly, \"git fetch\" accepts --depth=inf as\nan alternative to --depth=0. \"git clone\" also can. It just does not\nmake much sense for doing \"git clone --depth=inf\"\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Neither fetch-pack nor fetch uses parseopt, so Jonathan's OPT_INT_INF\n has no use here (yet).\n\n Documents updated.\n\n Documentation/fetch-options.txt     |    5 ++++-\n Documentation/git-fetch-pack.txt    |    1 +\n Documentation/technical/shallow.txt |    2 ++\n builtin/fetch-pack.c                |    4 ++--\n shallow.c                           |    2 +-\n t/t5500-fetch-pack.sh               |    8 ++++++++\n upload-pack.c                       |    8 ++++----\n 7 files changed, 22 insertions(+), 8 deletions(-)\n\ndiff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt\nindex 9333c42..0368afd 100644\n--- a/Documentation/fetch-options.txt\n+++ b/Documentation/fetch-options.txt\n@@ -10,7 +10,10 @@\n --depth=<depth>::\n \tDeepen the history of a 'shallow' repository created by\n \t`git clone` with `--depth=<depth>` option (see linkgit:git-clone[1])\n-\tby the specified number of commits.\n+\tby the specified number of commits. Specify 0 or \"inf\"\n+\tfor infinite depth, which may turn repository to a\n+\tnon-shallow one again (you may need --tags so that all\n+\tcommit chains are fully fetched).\n \n ifndef::git-pull[]\n --dry-run::\ndiff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt\nindex 4a8487c..ce15196 100644\n--- a/Documentation/git-fetch-pack.txt\n+++ b/Documentation/git-fetch-pack.txt\n@@ -70,6 +70,7 @@ OPTIONS\n \n --depth=<n>::\n \tLimit fetching to ancestor-chains not longer than n.\n+\tSpecify 0 or \"inf\" for infinite depth.\n \n --no-progress::\n \tDo not show the progress.\ndiff --git a/Documentation/technical/shallow.txt b/Documentation/technical/shallow.txt\nindex 559263a..eeca540 100644\n--- a/Documentation/technical/shallow.txt\n+++ b/Documentation/technical/shallow.txt\n@@ -47,3 +47,5 @@ It also writes an appropriate $GIT_DIR/shallow.\n You can deepen a shallow repository with \"git-fetch --depth 20\n repo branch\", which will fetch branch from repo, but stop at depth\n 20, updating $GIT_DIR/shallow.\n+\n+Depth 0 means infinite depth.\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 45d1824..df30381 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -844,8 +844,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n \t\t\t\tcontinue;\n \t\t\t}\n \t\t\tif (!prefixcmp(arg, \"--depth=\")) {\n-\t\t\t\targs.depth = strtol(arg + 8, NULL, 0);\n-\t\t\t\tif (args.depth <= 0)\n+\t\t\t\targs.depth = !strcmp(arg + 8, \"inf\") ? 0 : strtol(arg + 8, NULL, 0);\n+\t\t\t\tif (args.depth < 0)\n \t\t\t\t\tdie(\"Invalid depth %d\", args.depth);\n \t\t\t\targs.shallow = 1;\n \t\t\t\tcontinue;\ndiff --git a/shallow.c b/shallow.c\nindex 4d90eda..eab97c6 100644\n--- a/shallow.c\n+++ b/shallow.c\n@@ -85,7 +85,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,\n \t\t\t\t\tcontinue;\n \t\t\t\t*pointer = cur_depth;\n \t\t\t}\n-\t\t\tif (cur_depth < depth) {\n+\t\t\tif (!depth || cur_depth < depth) {\n \t\t\t\tif (p->next)\n \t\t\t\t\tadd_object_array(&p->item->object,\n \t\t\t\t\t\t\tNULL, &stack);\ndiff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh\nindex 18376d6..47fd87c 100755\n--- a/t/t5500-fetch-pack.sh\n+++ b/t/t5500-fetch-pack.sh\n@@ -248,4 +248,12 @@ test_expect_success 'clone shallow object count' '\n \tgrep \"^count: 52\" count.shallow\n '\n \n+test_expect_success 'infinite deepening (full repo)' '\n+\t(\n+\t\tcd shallow &&\n+\t\tgit fetch --depth=inf &&\n+\t\t! test -f .git/shallow\n+\t)\n+'\n+\n test_done\ndiff --git a/upload-pack.c b/upload-pack.c\nindex fc79dde..7b004b9 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -484,7 +484,7 @@ static void receive_needs(void)\n {\n \tstruct object_array shallows = {0, 0, NULL};\n \tstatic char line[1000];\n-\tint len, depth = 0;\n+\tint len, depth = -1;\n \n \tshallow_nr = 0;\n \tif (debug_fd)\n@@ -514,7 +514,7 @@ static void receive_needs(void)\n \t\tif (!prefixcmp(line, \"deepen \")) {\n \t\t\tchar *end;\n \t\t\tdepth = strtol(line + 7, &end, 0);\n-\t\t\tif (end == line + 7 || depth <= 0)\n+\t\t\tif (end == line + 7 || depth < 0)\n \t\t\t\tdie(\"Invalid deepen: %s\", line);\n \t\t\tcontinue;\n \t\t}\n@@ -562,9 +562,9 @@ static void receive_needs(void)\n \tif (!use_sideband && daemon_mode)\n \t\tno_progress = 1;\n \n-\tif (depth == 0 && shallows.nr == 0)\n+\tif (depth == -1 && shallows.nr == 0)\n \t\treturn;\n-\tif (depth > 0) {\n+\tif (depth >= 0) {\n \t\tstruct commit_list *result, *backup;\n \t\tint i;\n \t\tbackup = result = get_shallow_commits(&want_obj, depth,\n-- \n1.7.1.rc1.69.g24c2f7\n"},{"id":"148818","messageId":"20100824052846.GE20037@burratino","threadId":"24842","inReplyTo":"1282565304-3122-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 1/3] clone: warn users --depth is ignored in local clones","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-24T05:28:46Z","receivedAt":"2010-08-24T05:28:46Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyễn Thái Ngọc Duy wrote:\n\n> +++ b/builtin/clone.c\n> @@ -361,7 +361,7 @@ static void write_remote_refs(const struct ref *local_refs)\n>  \n>  int cmd_clone(int argc, const char **argv, const char *prefix)\n>  {\n> -\tint is_bundle = 0;\n> +\tint is_bundle = 0, is_local;\n>  \tstruct stat buf;\n>  \tconst char *repo_name, *repo, *work_tree, *git_dir;\n>  \tchar *path, *dir;\n> @@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char *prefix)\n>  \t\trepo = xstrdup(make_absolute_path(repo_name));\n>  \telse\n>  \t\trepo = repo_name;\n> +\tis_local = path && !is_bundle;\n> +\tif (is_local && option_depth)\n> +\t\twarning(\"--depth is ignored in local clones, use file:// instead.\");\n\nMicronit: this comma should be a semicolon or period.\n\nAs for the patch itself: I like it.  I could have used this advice\nabout a year ago.\n"},{"id":"148821","messageId":"AANLkTim-XWiZKdY20P+GEtPMTeTybhpBdkrGS=CMH56e@mail.gmail.com","threadId":"24842","inReplyTo":"20100824052846.GE20037@burratino","subject":"Re: [PATCH v2 1/3] clone: warn users --depth is ignored in local clones","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-24T05:52:36Z","receivedAt":"2010-08-24T05:52:36Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Aug 24, 2010 at 3:28 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Nguyễn Thái Ngọc Duy wrote:\n>\n>> +++ b/builtin/clone.c\n>> @@ -361,7 +361,7 @@ static void write_remote_refs(const struct ref\n>> *local_refs)\n>>\n>>  int cmd_clone(int argc, const char **argv, const char *prefix)\n>>  {\n>> -     int is_bundle = 0;\n>> +     int is_bundle = 0, is_local;\n>>       struct stat buf;\n>>       const char *repo_name, *repo, *work_tree, *git_dir;\n>>       char *path, *dir;\n>> @@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char\n>> *prefix)\n>>               repo = xstrdup(make_absolute_path(repo_name));\n>>       else\n>>               repo = repo_name;\n>> +     is_local = path && !is_bundle;\n>> +     if (is_local && option_depth)\n>> +             warning(\"--depth is ignored in local clones, use file://\n>> instead.\");\n>\n> Micronit: this comma should be a semicolon or period.\n\nI'd leave it for Junio to edit the patch if he likes it.\n-- \nDuy\n"},{"id":"148838","messageId":"20100824135341.GA6457@coredump.intra.peff.net","threadId":"24842","inReplyTo":"1282565304-3122-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-08-24T13:53:41Z","receivedAt":"2010-08-24T13:53:41Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 23, 2010 at 10:08:24PM +1000, Nguyễn Thái Ngọc Duy wrote:\n\n> Users can do --depth=2147483648 for infinite depth now. It just looks\n> ugly. So make \"0\" special (i.e. infinite depth) at plumbing/protocol\n> level.\n\nWhat happens if I connect to an older server? Shouldn't \"I understand\ndepth=0 is infinite\" be a server capability, and we hack around it by\nsending depth=2^32-1 when we have a modern client but an older server?\n\n-Peff\n"},{"id":"148845","messageId":"7vlj7wx99v.fsf@alter.siamese.dyndns.org","threadId":"24842","inReplyTo":"1282565304-3122-2-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH v2 2/3] fetch-pack: use args.shallow to detect shallow clone instead of args.depth","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-24T16:31:08Z","receivedAt":"2010-08-24T16:31:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n\nIsn't there any rationale for this change?  \"args.depth > 0 does not\nnecessarily mean we are in a shallow clone situation, because ...\" or\n\"using args.depth > 0 to check if we are in a shallow clone breaks under\nsuch and such conditions and here is a test case to reproduce the bug\"?\n"},{"id":"148852","messageId":"7vvd6zx63h.fsf@alter.siamese.dyndns.org","threadId":"24842","inReplyTo":"20100824135341.GA6457@coredump.intra.peff.net","subject":"Re: [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-24T17:39:46Z","receivedAt":"2010-08-24T17:39:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Aug 23, 2010 at 10:08:24PM +1000, Nguyễn Thái Ngọc Duy wrote:\n>\n>> Users can do --depth=2147483648 for infinite depth now. It just looks\n>> ugly. So make \"0\" special (i.e. infinite depth) at plumbing/protocol\n>> level.\n>\n> What happens if I connect to an older server? Shouldn't \"I understand\n> depth=0 is infinite\" be a server capability, and we hack around it by\n> sending depth=2^32-1 when we have a modern client but an older server?\n\nGood point.  Do we also need to find out how wide an int is on the other\nend in that case?\n"},{"id":"148853","messageId":"20100824174622.GA31283@sigill.intra.peff.net","threadId":"24842","inReplyTo":"7vvd6zx63h.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-08-24T17:46:22Z","receivedAt":"2010-08-24T17:46:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Aug 24, 2010 at 10:39:46AM -0700, Junio C Hamano wrote:\n\n> Jeff King <peff@peff.net> writes:\n> \n> > On Mon, Aug 23, 2010 at 10:08:24PM +1000, Nguyễn Thái Ngọc Duy wrote:\n> >\n> >> Users can do --depth=2147483648 for infinite depth now. It just looks\n> >> ugly. So make \"0\" special (i.e. infinite depth) at plumbing/protocol\n> >> level.\n> >\n> > What happens if I connect to an older server? Shouldn't \"I understand\n> > depth=0 is infinite\" be a server capability, and we hack around it by\n> > sending depth=2^32-1 when we have a modern client but an older server?\n> \n> Good point.  Do we also need to find out how wide an int is on the other\n> end in that case?\n\nI doubt it. We can probably assume that the remote can handle a signed\n32-bit depth (so really, my example should have been 2^31-1). If they\ncan't, then it would probably be at best an unsigned 16-bit int, in\nwhich case we could only handle a depth of 65535 commits. There are way\nmore than that in common repositories, so --depth with such an\nimplementation would be pretty broken already.\n\n-Peff\n"},{"id":"148892","messageId":"AANLkTimqwXmRYVZLkYtGLd5=e1B0hKKePA0XzOYPrifd@mail.gmail.com","threadId":"24842","inReplyTo":"20100824135341.GA6457@coredump.intra.peff.net","subject":"Re: [PATCH v2 3/3] {fetch,upload}-pack: allow --depth=0 for infinite depth","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-24T22:12:06Z","receivedAt":"2010-08-24T22:12:06Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Aug 24, 2010 at 11:53 PM, Jeff King <peff@peff.net> wrote:\n> On Mon, Aug 23, 2010 at 10:08:24PM +1000, Nguyễn Thái Ngọc Duy wrote:\n>\n>> Users can do --depth=2147483648 for infinite depth now. It just looks\n>> ugly. So make \"0\" special (i.e. infinite depth) at plumbing/protocol\n>> level.\n>\n> What happens if I connect to an older server? Shouldn't \"I understand\n> depth=0 is infinite\" be a server capability, and we hack around it by\n> sending depth=2^32-1 when we have a modern client but an older server?\n\nOlder servers won't accept depth=0, dying with \"Invalid deepen\"\nmessage. I don't really want to send a large number as a workaround,\nit just does not feel safe. Users can either play around with\n--depth=2^32-1, or upgrade servers.\n\nAnd in case of modern server and old client, old fetch-pack would\nnever send \"deepen 0\", so it's safe too, at least for current\nfetch-pack.\n-- \nDuy\n"},{"id":"148866","messageId":"AANLkTinWWweV43NP34iFXKVcyyu7uiovsDQxNKmdD0wL@mail.gmail.com","threadId":"24842","inReplyTo":"7vlj7wx99v.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/3] fetch-pack: use args.shallow to detect shallow clone instead of args.depth","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-24T22:14:20Z","receivedAt":"2010-08-24T22:14:20Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Aug 25, 2010 at 2:31 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n>\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>\n> Isn't there any rationale for this change?  \"args.depth > 0 does not\n> necessarily mean we are in a shallow clone situation, because ...\" or\n> \"using args.depth > 0 to check if we are in a shallow clone breaks under\n> such and such conditions and here is a test case to reproduce the bug\"?\n\n.. because args.depth=0 is now also a shallow clone situation, i.e. a\nvalid depth too.\n-- \nDuy\n"}]}