{"thread":{"id":"37391","subject":"Shallow clones with explicit history cutoff?","startedAt":"2014-08-21T15:39:13Z","lastAt":"2014-08-22T14:46:45Z","messageCount":3,"participants":["Matthias Urlichs","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"248063","messageId":"loom.20140821T171416-31@post.gmane.org","threadId":"37391","inReplyTo":null,"subject":"Shallow clones with explicit history cutoff?","fromName":"Matthias Urlichs","fromEmail":"matthias@urlichs.de","sentAt":"2014-08-21T15:39:13Z","receivedAt":"2014-08-21T15:39:13Z","isPatch":false,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi,\n\nuse case: I am packaging the FOO program for Debian. FOO is maintained in\ngit but it has a bunch of problems (e.g. because somebody mistakenly checked\nin a huge blob which would give the ).\n\nThe current workflow for this is to create a new branch, remove the\noffending bits if necessary, create a FOO-clean.tar.xz file, and ship that\nas \"original source\". I find that to be suboptimal.\n\nWhat I would like to have, instead, is a version of shallow cloning which\ncuts off not at a pre-determined depth, but at a given branch (or set of\nbranches). In other words, given\n\n            +-J--K  (packaged)\n           /    /\n  +-F--G--H----I    (clean)\n /       /\nA---B---C---D---E   (upstream)\n\na command \"git clone --shallow-until upstream $REPO\" (or however that would\nbe named) would create a shallow git archive which contains branches\npackaged+clean, with commits FGHIJK. In contrast, with --single-branch and\n--depth 4 I would get CGHIJK, which isn't what I'd want.\n\nAs I have not spent too much time with the git sources lately (as in \"None\nat all\"), some pointers where to start implementing this would be\nappreciated, assuming (a) this has a reasonable chance of landing in git and\n(b) nobody beats me to it. ;-)\n\n-- \n-- Matthias Urlichs\n"},{"id":"248111","messageId":"CACsJy8CSCcaFNxqqBLAnb5NXkwT+wVXCVmB8uF3RYwqRmz4tuw@mail.gmail.com","threadId":"37391","inReplyTo":"loom.20140821T171416-31@post.gmane.org","subject":"Re: Shallow clones with explicit history cutoff?","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2014-08-22T13:27:03Z","receivedAt":"2014-08-22T13:27:03Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Aug 21, 2014 at 10:39 PM, Matthias Urlichs <matthias@urlichs.de> wrote:\n> What I would like to have, instead, is a version of shallow cloning which\n> cuts off not at a pre-determined depth, but at a given branch (or set of\n> branches). In other words, given\n>\n>             +-J--K  (packaged)\n>            /    /\n>   +-F--G--H----I    (clean)\n>  /       /\n> A---B---C---D---E   (upstream)\n>\n> a command \"git clone --shallow-until upstream $REPO\" (or however that would\n> be named) would create a shallow git archive which contains branches\n> packaged+clean, with commits FGHIJK. In contrast, with --single-branch and\n> --depth 4 I would get CGHIJK, which isn't what I'd want.\n\nI would imagine a more generic mechanism \"git clone\n--shallow-rev=<rev> $REPO\" where you could pass anything that \"git\nrev-list\" can accept (maybe more restricted, and some verification\nrequired). --shallow-rev could be repeated. So in your case it could\nbe \"git clone --shallow-rev=\"^A\" $REPO\". We could even maybe turn\n--depth into a generic thing that is accepted by rev-list so that it\ncould be easily combined with other rev-list options (--shallow-rev\nand --depth are mutually exclusive).\n\n> As I have not spent too much time with the git sources lately (as in \"None\n> at all\"), some pointers where to start implementing this would be\n> appreciated, assuming (a) this has a reasonable chance of landing in git and\n> (b) nobody beats me to it. ;-)\n\nI'd like to see this implemented. You are not the first one\ncomplaining about the (lack of) flexibility of --depth. If you have\ntime, I may be able to support (I should not take on another topic\ngiven my many ongoing/unfinished topics). The starting point is\nupload-pack.c. And GIT_TRACE env variable will be your friend. Search\nfor get_shallow_commits(). There the function is supposed to traverse\ndown from want_obj and set/unset SHALLOW/NOT_SHALLOW flags  properly.\n\nSHALLOW flag should be set right before the cut-out commit (e.g. B and\nF if you want to cut A out). NOT_SHALLOW flags could be used to remove\nshallow lines in the receiver repo. If you traverse past an existing\nshallow point in the client (this is the fetch/pull case, not clone),\nthen you should set NOT_SHALLOW so the client knows to remove that\npoint from their $GIT_DIR/shallow. Once you set these properly, the\nrest should work.\n-- \nDuy\n"},{"id":"248118","messageId":"20140822144645.GS2049@smurf.noris.de","threadId":"37391","inReplyTo":"CACsJy8CSCcaFNxqqBLAnb5NXkwT+wVXCVmB8uF3RYwqRmz4tuw@mail.gmail.com","subject":"Re: Shallow clones with explicit history cutoff?","fromName":"Matthias Urlichs","fromEmail":"matthias@urlichs.de","sentAt":"2014-08-22T14:46:45Z","receivedAt":"2014-08-22T14:46:45Z","isPatch":false,"sender":{"key":"matthias@urlichs.de","avatar":"https://gravatar.com/avatar/2708905af227313eba6f2b2ae0f7d0259b5ac5d71baef58fe5a13c699ce0bbf0?d=mp&s=160"},"body":"Hi,\n\nDuy Nguyen:\n> On Thu, Aug 21, 2014 at 10:39 PM, Matthias Urlichs <matthias@urlichs.de> wrote:\n> > What I would like to have, instead, is a version of shallow cloning which\n> > cuts off not at a pre-determined depth, but at a given branch (or set of\n> > branches). In other words, given\n> >\n> >             +-J--K  (packaged)\n> >            /    /\n> >   +-F--G--H----I    (clean)\n> >  /       /\n> > A---B---C---D---E   (upstream)\n> >\n> > a command \"git clone --shallow-until upstream $REPO\" (or however that would\n> > be named) would create a shallow git archive which contains branches\n> > packaged+clean, with commits FGHIJK. In contrast, with --single-branch and\n> > --depth 4 I would get CGHIJK, which isn't what I'd want.\n> \n> I would imagine a more generic mechanism \"git clone\n> --shallow-rev=<rev> $REPO\" where you could pass anything that \"git\n> rev-list\" can accept (maybe more restricted, and some verification\n> required). --shallow-rev could be repeated. So in your case it could\n> be \"git clone --shallow-rev=\"^A\" $REPO\".\n\nUmm, no. ^E (or ^upstream) would do what I want. Hopefully. ;-)\n\nBut you're right, that would fit far better into the existing git\nparadigms.\n\n> > As I have not spent too much time with the git sources lately (as in \"None\n> > at all\"), some pointers where to start implementing this would be\n> > appreciated, assuming (a) this has a reasonable chance of landing in git and\n> > (b) nobody beats me to it. ;-)\n> \n> I'd like to see this implemented. You are not the first one\n> complaining about the (lack of) flexibility of --depth. If you have\n> time, I may be able to support (I should not take on another topic\n> given my many ongoing/unfinished topics).\n\nWelcome to the club. :-/\n\nThanks for the pointers. I'll see what I can do (and when).\n\n-- \n-- Matthias Urlichs\n"}]}