{"thread":{"id":"54212","subject":"Possible bug: --shallow-since and old branches","startedAt":"2020-09-08T19:59:09Z","lastAt":"2020-09-08T19:59:09Z","messageCount":1,"participants":["Tao Klerks"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"405190","messageId":"CAPMMpoicRnoBshbSNaF4Ns91b4WTE95EJJGzt1=cx9s_iYDOmA@mail.gmail.com","threadId":"54212","inReplyTo":null,"subject":"Possible bug: --shallow-since and old branches","fromName":"Tao Klerks","fromEmail":"tao@klerks.biz","sentAt":"2020-09-08T19:58:46Z","receivedAt":"2020-09-08T19:59:09Z","isPatch":false,"sender":{"key":"tao@klerks.biz","avatar":"https://avatars.githubusercontent.com/u/531704?v=4"},"body":"Hi folks,\n\nI've encountered very strange behavior when fetching a repo with\n--shallow-since, where I get many more commits than I expect in the\nrepo, and specifically when I count commits by branch I see old\nbranches where *every* commit is beyond the specified date threshold.\n\nI found a thread from 2018 in which something like this is discussed\n(https://public-inbox.org/git/20180522194854.GA29564@inner.h.apk.li/),\nbut I haven't completely understood the thread. It seems to address\nthe specific \"repo would be empty\" concern, but not necessarily the\nmore general \"I'm getting branches I shouldn't be getting\"\nconcern/case...?\n\nI can confirm that if I move my --shallow-since date to one that\n\"intersects\" the lifetime of a branch I am unexpectedly getting, then\nall of a sudden I only get those commits I expected on that branch.\n\nI can also confirm that in a recent version of git (since 2.16 I\nthink), if I set my refspec so *only* a \"too old\" branch matches, then\nI get the \"fatal: no commits selected for shallow requests\" error\nthat's expected. But if my refspec *also* matches a branch that *does*\nhave commits newer than the threshold, then I get the correct (newer)\ncommits of that recently-active branch, and *all* commits of the\ntoo-old branch that otherwise correctly refuses to fetch on its own.\n\nI *thought* I would be able get what I would have expected from a\n\"--shallow-since\" clone by:\n * Initializing a new repo\n * Adding the remote\n * Removing the default fetch refspec\n * Iterating remote heads, checking their commit dates, and adding\nthose valid/recent heads explicitly to the fetch refspec\n * Doing a fetch with  \"--shallow-since\"\n\n... however, I seem to have assumed some magic there: getting the\n\"most recent commit date\" for a remote ref apparently requires\nfetching it (to a depth of 1 at least) first??\n\nIs the behavior I'm seeing \"as designed\" for branches with no recent\ncommits, or is there a problem somewhere?\n\nBest regards,\nTao\n"}]}