{"thread":{"id":"24760","subject":"fully deepening a shallow clone","startedAt":"2010-08-17T00:49:05Z","lastAt":"2010-08-20T13:32:09Z","messageCount":16,"participants":["Joey Hess","Nguyen Thai Ngoc Duy","Daniel Johnson","Nguyễn Thái Ngọc Duy","Mikael Magnusson","Jakub Narebski","Ramkumar Ramachandra","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"148213","messageId":"20100817004905.GA8305@gnu.kitenet.net","threadId":"24760","inReplyTo":null,"subject":"fully deepening a shallow clone","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2010-08-17T00:49:05Z","receivedAt":"2010-08-17T00:49:05Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"git-pull(1):\n       --depth=<depth>\n           Deepen the history of a shallow repository created by git clone\n           with --depth=<depth> option (see git-clone(1)) by the specified\n           number of commits.\n\nWell, what if I want to deepen an existing shallow clone to include\nthe full history? In practice, something like --depth=100000000 is going\nto work, but in theory, that will eventually fail some day when there are\nenough commits. :)\n\n-- \nsee shy jo\n"},{"id":"148351","messageId":"AANLkTi=qEwcE6qSmAoNnqE-2Z41rjqPBSfgbaesQBPrA@mail.gmail.com","threadId":"24760","inReplyTo":"20100817004905.GA8305@gnu.kitenet.net","subject":"Re: fully deepening a shallow clone","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-18T09:36:08Z","receivedAt":"2010-08-18T09:36:08Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, Aug 17, 2010 at 10:49 AM, Joey Hess <joey@kitenet.net> wrote:\n> git-pull(1):\n>       --depth=<depth>\n>           Deepen the history of a shallow repository created by git clone\n>           with --depth=<depth> option (see git-clone(1)) by the specified\n>           number of commits.\n>\n> Well, what if I want to deepen an existing shallow clone to include\n> the full history? In practice, something like --depth=100000000 is going\n> to work, but in theory, that will eventually fail some day when there are\n> enough commits. :)\n\nI have always thought --depth=0 will make full repo again. Have you tried that?\n-- \nDuy\n"},{"id":"148362","messageId":"201008180854.18474.ComputerDruid@gmail.com","threadId":"24760","inReplyTo":"AANLkTi=qEwcE6qSmAoNnqE-2Z41rjqPBSfgbaesQBPrA@mail.gmail.com","subject":"Re: fully deepening a shallow clone","fromName":"Daniel Johnson","fromEmail":"computerdruid@gmail.com","sentAt":"2010-08-18T12:54:07Z","receivedAt":"2010-08-18T12:54:07Z","isPatch":false,"sender":{"key":"computerdruid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/34696?v=4"},"body":"On Wednesday 18 August 2010 05:36:08 Nguyen Thai Ngoc Duy wrote:\n> On Tue, Aug 17, 2010 at 10:49 AM, Joey Hess <joey@kitenet.net> wrote:\n> > git-pull(1):\n> >       --depth=<depth>\n> >           Deepen the history of a shallow repository created by git clone\n> >           with --depth=<depth> option (see git-clone(1)) by the specified\n> >           number of commits.\n> > \n> > Well, what if I want to deepen an existing shallow clone to include\n> > the full history? In practice, something like --depth=100000000 is going\n> > to work, but in theory, that will eventually fail some day when there are\n> > enough commits. :)\n> \n> I have always thought --depth=0 will make full repo again. Have you tried\n> that?\nI tried it myself. --depth=0 is the same as leaving the depth argument off \nentirely. If you are already working in a shallow clone fetch or pull without \narguments won't deepen it at all, only pull in new commits.\n\nI haven't been able to figure out a good way to solve this yet though.\n"},{"id":"148389","messageId":"20100818154838.GA4324@gnu.kitenet.net","threadId":"24760","inReplyTo":"AANLkTi=qEwcE6qSmAoNnqE-2Z41rjqPBSfgbaesQBPrA@mail.gmail.com","subject":"Re: fully deepening a shallow clone","fromName":"Joey Hess","fromEmail":"joey@kitenet.net","sentAt":"2010-08-18T15:48:38Z","receivedAt":"2010-08-18T15:48:38Z","isPatch":false,"sender":{"key":"joey@kitenet.net","avatar":"https://avatars.githubusercontent.com/u/16392?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n> On Tue, Aug 17, 2010 at 10:49 AM, Joey Hess <joey@kitenet.net> wrote:\n> > git-pull(1):\n> >       --depth=<depth>\n> >           Deepen the history of a shallow repository created by git clone\n> >           with --depth=<depth> option (see git-clone(1)) by the specified\n> >           number of commits.\n> >\n> > Well, what if I want to deepen an existing shallow clone to include\n> > the full history? In practice, something like --depth=100000000 is going\n> > to work, but in theory, that will eventually fail some day when there are\n> > enough commits. :)\n> \n> I have always thought --depth=0 will make full repo again. Have you tried that?\n\nI'd be happy if it did, but it pulls 0 revs actually.\n\n-- \nsee shy jo\n"},{"id":"148443","messageId":"1282214437-16384-1-git-send-email-pclouds@gmail.com","threadId":"24760","inReplyTo":"201008180854.18474.ComputerDruid@gmail.com","subject":"[PATCH 1/3] clone: do not accept --depth on local clones","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-19T10:40:35Z","receivedAt":"2010-08-19T10:40:35Z","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/clone.c |    7 +++++--\n 1 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/clone.c b/builtin/clone.c\nindex efb1e6f..215c432 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\tdie(\"local clone with --depth does not make sense\");\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":"148444","messageId":"1282214437-16384-2-git-send-email-pclouds@gmail.com","threadId":"24760","inReplyTo":"201008180854.18474.ComputerDruid@gmail.com","subject":"[PATCH 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-19T10:40:36Z","receivedAt":"2010-08-19T10:40:36Z","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":"148445","messageId":"1282214437-16384-3-git-send-email-pclouds@gmail.com","threadId":"24760","inReplyTo":"201008180854.18474.ComputerDruid@gmail.com","subject":"[PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-19T10:40:37Z","receivedAt":"2010-08-19T10:40:37Z","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 The funny thing is, even with --depth=0, I still have two commit grafts\n in $GIT_DIR/shallow, which are grafts of tags. I think there is a bug somewhere..\n\n builtin/fetch-pack.c |    2 +-\n shallow.c            |    2 +-\n upload-pack.c        |    8 ++++----\n 3 files changed, 6 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex 45d1824..7d7af2e 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -845,7 +845,7 @@ 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\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/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":"148451","messageId":"201008191031.40230.ComputerDruid@gmail.com","threadId":"24760","inReplyTo":"1282214437-16384-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/3] clone: do not accept --depth on local clones","fromName":"Daniel Johnson","fromEmail":"computerdruid@gmail.com","sentAt":"2010-08-19T14:31:32Z","receivedAt":"2010-08-19T14:31:32Z","isPatch":true,"sender":{"key":"computerdruid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/34696?v=4"},"body":"On Thursday 19 August 2010 06:40:35 you wrote:\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/clone.c |    7 +++++--\n>  1 files changed, 5 insertions(+), 2 deletions(-)\nCan you make it a little clearer what the rationale is for this change? Why \nwouldn't you be able to do a limited-depth local clone? Seems like this would \nbreak some tests, and even if not, would prevent the writing of them.\n"},{"id":"148485","messageId":"AANLkTimouObkUFVff8GQgGy7cDMAHXTDxGQx0gJUOO2Q@mail.gmail.com","threadId":"24760","inReplyTo":"1282214437-16384-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 1/3] clone: do not accept --depth on local clones","fromName":"Mikael Magnusson","fromEmail":"mikachu@gmail.com","sentAt":"2010-08-19T20:49:06Z","receivedAt":"2010-08-19T20:49:06Z","isPatch":true,"sender":{"key":"mikachu@gmail.com","avatar":null},"body":"2010/8/19 Nguyễn Thái Ngọc Duy <pclouds@gmail.com>:\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> ---\n>  builtin/clone.c |    7 +++++--\n>  1 files changed, 5 insertions(+), 2 deletions(-)\n>\n> diff --git a/builtin/clone.c b/builtin/clone.c\n> index efb1e6f..215c432 100644\n> --- a/builtin/clone.c\n> +++ b/builtin/clone.c\n> @@ -414,6 +414,9 @@ int cmd_clone(int argc, const char **argv, const char *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> +               die(\"local clone with --depth does not make sense\");\n>\n>        if (argc == 2)\n>                dir = xstrdup(argv[1]);\n\nWouldn't it be more helpful to also say \"Use the file:///blabla syntax\ninstead\" or just automatically fall back to that protocol when --depth\nis used?\n\n-- \nMikael Magnusson\n"},{"id":"148487","messageId":"m362z6pact.fsf@localhost.localdomain","threadId":"24760","inReplyTo":"1282214437-16384-3-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-08-19T21:22:14Z","receivedAt":"2010-08-19T21:22:14Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?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>  The funny thing is, even with --depth=0, I still have two commit grafts\n>  in $GIT_DIR/shallow, which are grafts of tags. I think there is a bug somewhere..\n> \n>  builtin/fetch-pack.c |    2 +-\n>  shallow.c            |    2 +-\n>  upload-pack.c        |    8 ++++----\n>  3 files changed, 6 insertions(+), 6 deletions(-)\n> \n\nFist, it lacks documentation update that --depth=0 means infinite\ndepth (making repository not-shallow).\n\nSecond, it would be nice (though probably not easy with parseopt, as\nit would require hacks/extensions) to be able to use --depth=inf\n(like wget supports '-l inf') to mean infinite depth...\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"},{"id":"148489","messageId":"AANLkTinQZxpLdFiCFH3kDTFVQ-ZLjJ1PEdmmsJSb=0YD@mail.gmail.com","threadId":"24760","inReplyTo":"m362z6pact.fsf@localhost.localdomain","subject":"Re: [PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-19T22:11:45Z","receivedAt":"2010-08-19T22:11:45Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Aug 20, 2010 at 7:22 AM, Jakub Narebski <jnareb@gmail.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>>  The funny thing is, even with --depth=0, I still have two commit grafts\n>>  in $GIT_DIR/shallow, which are grafts of tags. I think there is a bug\n>> somewhere..\n>>\n>>  builtin/fetch-pack.c |    2 +-\n>>  shallow.c            |    2 +-\n>>  upload-pack.c        |    8 ++++----\n>>  3 files changed, 6 insertions(+), 6 deletions(-)\n>>\n>\n> Fist, it lacks documentation update that --depth=0 means infinite\n> depth (making repository not-shallow).\n\nYeah. I would do documentation and tests later once I figured out why\n--depth=0 did not give me full repo. It turns out I need --tags to\n(refetch?) tags and have full repo.\n\n> Second, it would be nice (though probably not easy with parseopt, as\n> it would require hacks/extensions) to be able to use --depth=inf\n> (like wget supports '-l inf') to mean infinite depth...\n\nHmm.. make --depth a string parameter and fetch-pack should parse the\nparameter itself, like git-clone. Good idea.\n-- \nDuy\n"},{"id":"148490","messageId":"AANLkTimHKc7y7ktAkAUffLzOtMGxqWO0i2nOWWuo4N9J@mail.gmail.com","threadId":"24760","inReplyTo":"201008191031.40230.ComputerDruid@gmail.com","subject":"Re: [PATCH 1/3] clone: do not accept --depth on local clones","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-19T22:15:19Z","receivedAt":"2010-08-19T22:15:19Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Fri, Aug 20, 2010 at 12:31 AM, Daniel Johnson\n<computerdruid@gmail.com> wrote:\n> On Thursday 19 August 2010 06:40:35 you wrote:\n>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>> ---\n>>  builtin/clone.c |    7 +++++--\n>>  1 files changed, 5 insertions(+), 2 deletions(-)\n> Can you make it a little clearer what the rationale is for this change? Why\n> wouldn't you be able to do a limited-depth local clone? Seems like this\n> would\n> break some tests, and even if not, would prevent the writing of them.\n\nIt's been like this ever since and it puzzled me, \"why 'git clone\n--depth=2 ~/foo' did not work? What did I do?\" Will do as Mikael\nsuggested.\n-- \nDuy\n"},{"id":"148517","messageId":"201008201122.09392.jnareb@gmail.com","threadId":"24760","inReplyTo":"AANLkTinQZxpLdFiCFH3kDTFVQ-ZLjJ1PEdmmsJSb=0YD@mail.gmail.com","subject":"Re: [PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-08-20T09:22:08Z","receivedAt":"2010-08-20T09:22:08Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"On Fri, Aug 20, 2010, Nguyen Thai Ngoc Duy wrote:\n> On Fri, Aug 20, 2010 at 7:22 AM, Jakub Narebski <jnareb@gmail.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>>>  The funny thing is, even with --depth=0, I still have two commit grafts\n>>>  in $GIT_DIR/shallow, which are grafts of tags. I think there is a bug\n>>> somewhere..\n>>>\n>>>  builtin/fetch-pack.c |    2 +-\n>>>  shallow.c            |    2 +-\n>>>  upload-pack.c        |    8 ++++----\n>>>  3 files changed, 6 insertions(+), 6 deletions(-)\n>>>\n>>\n>> Fist, it lacks documentation update that --depth=0 means infinite\n>> depth (making repository not-shallow).\n> \n> Yeah. I would do documentation and tests later once I figured out why\n> --depth=0 did not give me full repo. It turns out I need --tags to\n> (refetch?) tags and have full repo.\n\nPerhaps --depth=0 should also work as if --tags were specified on\ncommand line?  BTW. shouldn't git fetch tags that point to commits\nthat got doenloaded because of deepening the clone?\n\n> \n>> Second, it would be nice (though probably not easy with parseopt, as\n>> it would require hacks/extensions) to be able to use --depth=inf\n>> (like wget supports '-l inf') to mean infinite depth...\n> \n> Hmm.. make --depth a string parameter and fetch-pack should parse the\n> parameter itself, like git-clone. Good idea.\n\nIf there were more options that use <n> == 0 to actually mean unlimited\n(infinity), perhaps it would be better to extend parseopt to provide for\nsuch situation, e.g. OPT_INT_INF or something.  This way we would avoid\ncode duplication.\n\n... oh, wait, the newly introduced[1] git-merge `--log-limit' option\nuses --log-limit=0 to mean unlimited.\n\n[1] http://permalink.gmane.org/gmane.comp.version-control.git/153984\n    Message-ID: <20100820081641.GA32127@burratino>\n    Subject: Re: wishlist bugreport: make limit configurable for do_fmt_merge_msg (merge.log)\n\n-- \nJakub Narebski\nPoland\n"},{"id":"148519","messageId":"20100820092847.GF12794@kytes","threadId":"24760","inReplyTo":"201008201122.09392.jnareb@gmail.com","subject":"Re: [PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-08-20T09:28:51Z","receivedAt":"2010-08-20T09:28:51Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Jakub,\n\nJakub Narebski writes:\n> >> Second, it would be nice (though probably not easy with parseopt, as\n> >> it would require hacks/extensions) to be able to use --depth=inf\n> >> (like wget supports '-l inf') to mean infinite depth...\n> > \n> > Hmm.. make --depth a string parameter and fetch-pack should parse the\n> > parameter itself, like git-clone. Good idea.\n> \n> If there were more options that use <n> == 0 to actually mean unlimited\n> (infinity), perhaps it would be better to extend parseopt to provide for\n> such situation, e.g. OPT_INT_INF or something.  This way we would avoid\n> code duplication.\n> \n> ... oh, wait, the newly introduced[1] git-merge `--log-limit' option\n> uses --log-limit=0 to mean unlimited.\n> \n> [1] http://permalink.gmane.org/gmane.comp.version-control.git/153984\n>     Message-ID: <20100820081641.GA32127@burratino>\n>     Subject: Re: wishlist bugreport: make limit configurable for do_fmt_merge_msg (merge.log)\n\nJust outdated by a few seconds. Johannes suggested that we reuse\nmerge.log, making it a bool_or_int option. I What about using -1 to\nmean infinity and reserving 0 for false instead?\n\n-- Ram\n"},{"id":"148543","messageId":"20100820115527.GR10407@burratino","threadId":"24760","inReplyTo":"201008201122.09392.jnareb@gmail.com","subject":"[PATCH] grep -A/-B/-Cinfinity to get full context","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-20T11:55:27Z","receivedAt":"2010-08-20T11:55:27Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Just a proof of concept.\n\nCc: René Scharfe <rene.scharfe@lsrfire.ath.cx>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJakub Narebski wrote:\n\n> If there were more options that use <n> == 0 to actually mean unlimited\n> (infinity), perhaps it would be better to extend parseopt to provide for\n> such situation, e.g. OPT_INT_INF or something.\n\nSomething like this, maybe.\n\n Documentation/technical/api-parse-options.txt |    6 ++++++\n builtin/grep.c                                |    8 ++++++--\n grep.c                                        |    8 +++++---\n grep.h                                        |    4 ++--\n parse-options.c                               |   21 +++++++++++++++++++++\n parse-options.h                               |    4 ++++\n 6 files changed, 44 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\nindex 312e3b2..f152a3f 100644\n--- a/Documentation/technical/api-parse-options.txt\n+++ b/Documentation/technical/api-parse-options.txt\n@@ -160,6 +160,12 @@ There are some macros to easily define options:\n \tIntroduce an option with integer argument.\n \tThe integer is put into `int_var`.\n \n+`OPT_INT_INF(short, long, &int_var, inf_val, description)`::\n+\tIntroduce an option with integer argument.\n+\tThe integer is put into `int_var`.  If the special value\n+\t\"inf\" (or \"infinity\") is used as an argument, then `inf_val`\n+\tis put into `int_var`.\n+\n `OPT_DATE(short, long, &int_var, description)`::\n \tIntroduce an option with date argument, see `approxidate()`.\n \tThe timestamp is put into `int_var`.\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex 597f76b..9fbc985 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -750,6 +750,10 @@ static int context_callback(const struct option *opt, const char *arg,\n \t\tgrep_opt->pre_context = grep_opt->post_context = 0;\n \t\treturn 0;\n \t}\n+\tif (!strcasecmp(arg, \"inf\") || !strcasecmp(arg, \"infinity\")) {\n+\t\tgrep_opt->pre_context = grep_opt->post_context = -1;\n+\t\treturn 0;\n+\t}\n \tvalue = strtol(arg, (char **)&endp, 10);\n \tif (*endp) {\n \t\treturn error(\"switch `%c' expects a numerical value\",\n@@ -890,9 +894,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_CALLBACK('C', NULL, &opt, \"n\",\n \t\t\t\"show <n> context lines before and after matches\",\n \t\t\tcontext_callback),\n-\t\tOPT_INTEGER('B', NULL, &opt.pre_context,\n+\t\tOPT_INT_INF('B', NULL, &opt.pre_context, -1,\n \t\t\t\"show <n> context lines before matches\"),\n-\t\tOPT_INTEGER('A', NULL, &opt.post_context,\n+\t\tOPT_INT_INF('A', NULL, &opt.post_context, -1,\n \t\t\t\"show <n> context lines after matches\"),\n \t\tOPT_NUMBER_CALLBACK(&opt, \"shortcut for -C NUM\",\n \t\t\tcontext_callback),\ndiff --git a/grep.c b/grep.c\nindex 82fb349..793d41f 100644\n--- a/grep.c\n+++ b/grep.c\n@@ -687,7 +687,7 @@ static void show_pre_context(struct grep_opt *opt, const char *name, char *buf,\n \tunsigned cur = lno, from = 1, funcname_lno = 0;\n \tint funcname_needed = opt->funcname;\n \n-\tif (opt->pre_context < lno)\n+\tif (opt->pre_context >= 0 && opt->pre_context < lno)\n \t\tfrom = lno - opt->pre_context;\n \tif (from <= opt->last_shown)\n \t\tfrom = opt->last_shown + 1;\n@@ -861,7 +861,8 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \t\t */\n \t\tif (try_lookahead\n \t\t    && !(last_hit\n-\t\t\t && lno <= last_hit + opt->post_context)\n+\t\t\t && (opt->post_context < 0\n+\t\t\t     || lno <= last_hit + opt->post_context))\n \t\t    && look_ahead(opt, &left, &lno, &bol))\n \t\t\tbreak;\n \t\teol = end_of_line(bol, &left);\n@@ -916,7 +917,8 @@ static int grep_buffer_1(struct grep_opt *opt, const char *name,\n \t\t\tlast_hit = lno;\n \t\t}\n \t\telse if (last_hit &&\n-\t\t\t lno <= last_hit + opt->post_context) {\n+\t\t\t (opt->post_context < 0 ||\n+\t\t\t  lno <= last_hit + opt->post_context)) {\n \t\t\t/* If the last hit is within the post context,\n \t\t\t * we need to show this line.\n \t\t\t */\ndiff --git a/grep.h b/grep.h\nindex efa8cff..13aae94 100644\n--- a/grep.h\n+++ b/grep.h\n@@ -95,8 +95,8 @@ struct grep_opt {\n \tchar color_selected[COLOR_MAXLEN];\n \tchar color_sep[COLOR_MAXLEN];\n \tint regflags;\n-\tunsigned pre_context;\n-\tunsigned post_context;\n+\tint pre_context;\n+\tint post_context;\n \tunsigned last_shown;\n \tint show_hunk_mark;\n \tvoid *priv;\ndiff --git a/parse-options.c b/parse-options.c\nindex 0fa79bc..b299125 100644\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -612,6 +612,27 @@ int parse_opt_approxidate_cb(const struct option *opt, const char *arg,\n \treturn 0;\n }\n \n+int parse_opt_infinity_cb(const struct option *opt, const char *arg,\n+\t\t\t  int unset)\n+{\n+\tconst char *endp;\n+\n+\tif (unset) {\n+\t\t*(int *)opt->value = 0;\n+\t\treturn 0;\n+\t}\n+\tif (!arg)\n+\t\treturn opterror(opt, \"expects a numerical value\", 0);\n+\tif (!strcasecmp(arg, \"inf\") || !strcasecmp(arg, \"infinity\")) {\n+\t\t*(int *)opt->value = opt->defval;\n+\t\treturn 0;\n+\t}\n+\t*(int *)opt->value = strtol(arg, (char **)&endp, 10);\n+\tif (*endp)\n+\t\treturn opterror(opt, \"expects a numerical value\", 0);\n+\treturn 0;\n+}\n+\n int parse_opt_color_flag_cb(const struct option *opt, const char *arg,\n \t\t\t    int unset)\n {\ndiff --git a/parse-options.h b/parse-options.h\nindex 7435cdb..6ae041a 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -126,6 +126,9 @@ struct option {\n #define OPT_STRING(s, l, v, a, h)   { OPTION_STRING,  (s), (l), (v), (a), (h) }\n #define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n \t\t\t\t      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n+#define OPT_INT_INF(s, l, v, i, h) \\\n+\t{ OPTION_CALLBACK, (s), (l), (v), \"n\", (h), 0, \\\n+\t  parse_opt_infinity_cb, (intptr_t)(i) }\n #define OPT_DATE(s, l, v, h) \\\n \t{ OPTION_CALLBACK, (s), (l), (v), \"time\",(h), 0, \\\n \t  parse_opt_approxidate_cb }\n@@ -193,6 +196,7 @@ extern int parse_options_concat(struct option *dst, size_t, struct option *src);\n /*----- some often used options -----*/\n extern int parse_opt_abbrev_cb(const struct option *, const char *, int);\n extern int parse_opt_approxidate_cb(const struct option *, const char *, int);\n+extern int parse_opt_infinity_cb(const struct option *, const char *, int);\n extern int parse_opt_color_flag_cb(const struct option *, const char *, int);\n extern int parse_opt_verbosity_cb(const struct option *, const char *, int);\n extern int parse_opt_with_commit(const struct option *, const char *, int);\n-- \n1.7.2.2.536.g42dab.dirty\n"},{"id":"148561","messageId":"20100820133206.GD9448@kytes","threadId":"24760","inReplyTo":"20100820115527.GR10407@burratino","subject":"Re: [PATCH] grep -A/-B/-Cinfinity to get full context","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2010-08-20T13:32:09Z","receivedAt":"2010-08-20T13:32:09Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Hi Jonathan,\n\nJonathan Nieder writes:\n> Just a proof of concept.\n> \n> Cc: René Scharfe <rene.scharfe@lsrfire.ath.cx>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n\nElegant. OPT_INTEGER for integers without the ability to represent\ninfinity, and OPT_INT_INF for integers with definite representation\nfor infinity.\n\n> diff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\n> index 312e3b2..f152a3f 100644\n> --- a/Documentation/technical/api-parse-options.txt\n> +++ b/Documentation/technical/api-parse-options.txt\n> @@ -160,6 +160,12 @@ There are some macros to easily define options:\n>  \tIntroduce an option with integer argument.\n>  \tThe integer is put into `int_var`.\n>  \n> +`OPT_INT_INF(short, long, &int_var, inf_val, description)`::\n> +\tIntroduce an option with integer argument.\n> +\tThe integer is put into `int_var`.  If the special value\n> +\t\"inf\" (or \"infinity\") is used as an argument, then `inf_val`\n> +\tis put into `int_var`.\n\nNice. You're making the caller pass the `inf_val` argument - this way,\neach caller can figure out some integer that's outside its sane range\nand use that to represent infinity.\n\n> -\t\tOPT_INTEGER('B', NULL, &opt.pre_context,\n> +\t\tOPT_INT_INF('B', NULL, &opt.pre_context, -1,\n>  \t\t\t\"show <n> context lines before matches\"),\n> -\t\tOPT_INTEGER('A', NULL, &opt.post_context,\n> +\t\tOPT_INT_INF('A', NULL, &opt.post_context, -1,\n>  \t\t\t\"show <n> context lines after matches\"),\n>  \t\tOPT_NUMBER_CALLBACK(&opt, \"shortcut for -C NUM\",\n>  \t\t\tcontext_callback),\n\nFor many cases, -1 is probably a good value to choose.\n\n> diff --git a/parse-options.h b/parse-options.h\n> index 7435cdb..6ae041a 100644\n> --- a/parse-options.h\n> +++ b/parse-options.h\n> @@ -126,6 +126,9 @@ struct option {\n>  #define OPT_STRING(s, l, v, a, h)   { OPTION_STRING,  (s), (l), (v), (a), (h) }\n>  #define OPT_UYN(s, l, v, h)         { OPTION_CALLBACK, (s), (l), (v), NULL, \\\n>  \t\t\t\t      (h), PARSE_OPT_NOARG, &parse_opt_tertiary }\n> +#define OPT_INT_INF(s, l, v, i, h) \\\n> +\t{ OPTION_CALLBACK, (s), (l), (v), \"n\", (h), 0, \\\n> +\t  parse_opt_infinity_cb, (intptr_t)(i) }\n\nOkay, you've used the same character \"n\" for OPT_INTEGER and OPT_INT_INF.\n\nThanks for the pleasant reading.\n\n-- Ram\n"}]}