{"thread":{"id":"51571","subject":"cannot clone --single-commit instead of --single-branch","startedAt":"2019-08-01T20:52:46Z","lastAt":"2019-08-02T03:08:58Z","messageCount":5,"participants":["Alexander Mills","Bryan Turner","Jonathan Nieder","Mike Hommey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"379777","messageId":"CA+KyZp6mYx4C22syAu=W2Okf7tDwtQ+7vVUBaQ-2D70PTS+GaA@mail.gmail.com","threadId":"51571","inReplyTo":null,"subject":"cannot clone --single-commit instead of --single-branch","fromName":"Alexander Mills","fromEmail":"alexander.d.mills@gmail.com","sentAt":"2019-08-01T20:52:32Z","receivedAt":"2019-08-01T20:52:46Z","isPatch":false,"sender":{"key":"alexander.d.mills@gmail.com","avatar":"https://gravatar.com/avatar/8accf19b85aa1020f85582e1f001860f853ce55767c226545a0825a2fcd99f04?d=mp&s=160"},"body":"Looking for help with this problem:\n\nhttps://stackoverflow.com/questions/57316783/git-clone-single-branch-does-not-work-for-sha-commit-ids\n\nEssentially looking for:\n\ngit clone --single-commit\n\nsince\n\ngit clone --single-branch=<sha>\n\ndoesn't seem to work?\nany help appreciated.\n\n-alex\n\n\n-- \nAlexander D. Mills\nNew cell phone # (415)730-1805\nalexander.d.mills@gmail.com\n\nwww.linkedin.com/pub/alexander-mills/b/7a5/418/\n"},{"id":"379794","messageId":"CAGyf7-F2qs2=51hdA-1BB=12w7GiwaVZ974eYKFzu-=OKj8Q=g@mail.gmail.com","threadId":"51571","inReplyTo":"CA+KyZp6mYx4C22syAu=W2Okf7tDwtQ+7vVUBaQ-2D70PTS+GaA@mail.gmail.com","subject":"Re: cannot clone --single-commit instead of --single-branch","fromName":"Bryan Turner","fromEmail":"bturner@atlassian.com","sentAt":"2019-08-01T22:40:40Z","receivedAt":"2019-08-01T22:40:53Z","isPatch":false,"sender":{"key":"bturner@atlassian.com","avatar":"https://gravatar.com/avatar/16bcf3167981c1ef7c804e502642366d888a35b0d0b0a4ca01fdc442aa1acb1e?d=mp&s=160"},"body":"On Thu, Aug 1, 2019 at 1:52 PM Alexander Mills\n<alexander.d.mills@gmail.com> wrote:\n>\n> Looking for help with this problem:\n>\n> https://stackoverflow.com/questions/57316783/git-clone-single-branch-does-not-work-for-sha-commit-ids\n>\n> Essentially looking for:\n>\n> git clone --single-commit\n\nThere's no such option, which will be why it doesn't work. I suspect\nthe closest feature is a shallow clone, performed using git clone\n--depth=1. That's still not going to allow passing an arbitrary SHA-1,\nthough; it'll only support a branch name, the same as --single-branch,\nwhich --depth implies (unless --no-single-branch is specified, at\nwhich point it fetches the depth for all branches).\n\nPromisor remotes and other in-flight changes might help provide some\nof what you're looking for, but I'm not aware of any already-available\nsolution. Perhaps something like VFS for Git, if whatever hosting\nsolution you're using supports it.\n\nHope this helps!\nBryan\n"},{"id":"379799","messageId":"20190802024322.GC54514@google.com","threadId":"51571","inReplyTo":"CAGyf7-F2qs2=51hdA-1BB=12w7GiwaVZ974eYKFzu-=OKj8Q=g@mail.gmail.com","subject":"Re: cannot clone --single-commit instead of --single-branch","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-08-02T02:43:22Z","receivedAt":"2019-08-02T02:43:27Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi,\n\nBryan Turner wrote:\n\n> Promisor remotes and other in-flight changes might help provide some\n> of what you're looking for, but I'm not aware of any already-available\n> solution.\n\nYou can do\n\n\tgit clone --no-checkout --filter=blob:none $url repo\n\tcd repo\n\tgit checkout $commit\n\nThat gives you commits and trees from other commits, but the only blobs\nit downloads are from the named commit.\n\nUsing the existing tree filtering features to limit the trees fetched\nand/or writing a patch for commit filtering are left as exercises to\nthe reader.\n\nThanks and hope that helps,\nJonathan\n"},{"id":"379800","messageId":"20190802025728.GD54514@google.com","threadId":"51571","inReplyTo":"CA+KyZp6mYx4C22syAu=W2Okf7tDwtQ+7vVUBaQ-2D70PTS+GaA@mail.gmail.com","subject":"Re: cannot clone --single-commit instead of --single-branch","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2019-08-02T02:57:28Z","receivedAt":"2019-08-02T02:57:32Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"(cc: Duy, who might enjoy this walk through history)\nHi,\n\nAlexander Mills wrote:\n\n> git clone --single-branch=<sha>\n>\n> doesn't seem to work?\n\nI've occasionally wanted something like this (actually, I've wanted to\npass a refname like \"refs/meta/config\").  builtin/clone.c contains\n\n\tstatic struct ref *find_remote_branch(const struct ref *refs, const char *branch)\n\t{\n\t\tstruct ref *ref;\n\t\tstruct strbuf head = STRBUF_INIT;\n\t\tstrbuf_addstr(&head, \"refs/heads/\");\n\t\tstrbuf_addstr(&head, branch);\n\t\tref = find_ref_by_name(refs, head.buf);\n\t\tstrbuf_release(&head);\n\n\t\tif (ref)\n\t\t\treturn ref;\n\nSo far, what one would expect.\n\n\t\tstrbuf_addstr(&head, \"refs/tags/\");\n\t\tstrbuf_addstr(&head, branch);\n\t\tref = find_ref_by_name(refs, head.buf);\n\t\tstrbuf_release(&head);\n\nWait a second: a tag isn't a branch, so why do we accept it as a\nvalue for --branch?  So this is stretching definitions a little\nalready.\n\n\"git log -L:find_remote_branch:builtin/clone.c\" tells me this is from\nv1.7.10-rc0~125^2~3 (clone: allow --branch to take a tag, 2012-01-16):\n\n\tBecause a tag ref cannot be put to HEAD, HEAD will become detached.\n\tThis is consistent with \"git checkout <tag>\".\n\nI think ideally we could first check for a sha1 and then try the full\nset of patterns from ref_rev_parse_rules.  What do you think?  Would\nyou be interested in taking a stab at it?\n\nThanks,\nJonathan\n"},{"id":"379801","messageId":"20190802030740.fr2kkpom5bvknksk@glandium.org","threadId":"51571","inReplyTo":"20190802024322.GC54514@google.com","subject":"Re: cannot clone --single-commit instead of --single-branch","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2019-08-02T03:07:40Z","receivedAt":"2019-08-02T03:08:58Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Thu, Aug 01, 2019 at 07:43:22PM -0700, Jonathan Nieder wrote:\n> Hi,\n> \n> Bryan Turner wrote:\n> \n> > Promisor remotes and other in-flight changes might help provide some\n> > of what you're looking for, but I'm not aware of any already-available\n> > solution.\n> \n> You can do\n> \n> \tgit clone --no-checkout --filter=blob:none $url repo\n\nTIL. Why doesn't --filter appear in the git-clone manual page?\n\nMike\n"}]}