{"thread":{"id":"62361","subject":"Feature Request : Get repo size without cloning","startedAt":"2024-10-18T09:50:12Z","lastAt":"2024-10-18T23:07:49Z","messageCount":2,"participants":["Aswin Benny","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"505418","messageId":"CAHJ9C2JNVH6SmE5FoR7u7Z=5eynm8QfW4ZHMeA6dvP0FodxNWA@mail.gmail.com","threadId":"62361","inReplyTo":null,"subject":"Feature Request : Get repo size without cloning","fromName":"Aswin Benny","fromEmail":"aswinbenny.edu@gmail.com","sentAt":"2024-10-18T09:50:00Z","receivedAt":"2024-10-18T09:50:12Z","isPatch":false,"sender":{"key":"aswinbenny.edu@gmail.com","avatar":null},"body":"I would like to request the following features to git :\n1. A command or feature to get the size of the repo without cloning it\nto the system\n2. An option to know the size of objects that will be downloaded forehand.\n\nContext :\nI am a student and I was building a SAAS tool that analyses code.I\nneed to prevent people from cloning repos more than 1 GB.\nI could use the APIs from github and gitlab but there is no common\nmethod amongst them.\nCurrently I am doing a shallow clone and after cloning check if the\nrepo size exceeds 1GB, if it exceeds I will delete it. I have to clone\nthe repos to know the repo size.\nThanks in advance.\n"},{"id":"505479","messageId":"ZxLqQlNEPKT6CoGh@tapette.crustytoothpaste.net","threadId":"62361","inReplyTo":"CAHJ9C2JNVH6SmE5FoR7u7Z=5eynm8QfW4ZHMeA6dvP0FodxNWA@mail.gmail.com","subject":"Re: Feature Request : Get repo size without cloning","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2024-10-18T23:07:46Z","receivedAt":"2024-10-18T23:07:49Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2024-10-18 at 09:50:00, Aswin Benny wrote:\n> I would like to request the following features to git :\n> 1. A command or feature to get the size of the repo without cloning it\n> to the system\n> 2. An option to know the size of objects that will be downloaded forehand.\n\nThese are actually really difficult to know without actually performing\nthe operation.  For example, GitHub and many other forges store all of\nthe objects in a repository network in a single alternate, but only a\npart of those objects (the ones in the repository you're cloning or\nfetching) are included.\n\nIn addition, to know the size of the pack being generated, there's no\nmore efficient way than generating the pack.  For example, a repository\nwith identical structure but containing 500 MB of text files (source\ncode, literature, etc.) will be much smaller than a repository with 500\nMB of random data because the former deltifies and compresses much\nbetter than the latter.  We don't know the size of the pack file being\nsent until we've actually compressed and deltified the objects.\n\nWe can, of course, make estimations of this data based on what's on disk\non the server side.  But, just like with GitHub's API, it's not always\npossible to know exactly, and some users will be unhappy with a value\nthat's not exactly correct.  (I can confirm there are users who feel\nthis way about GitHub's API functionality, and I understand their\nconcerns.)\n\nGiven this, I'm not super excited about adding this feature to Git,\nbecause I think it will set us up for a lot of complaints when the data\nisn't exactly correct, especially when the data is far off from the\nactual value, and I don't think the utility is worth it.  But perhaps\nyou or someone else can write a patch and it will be accepted, with the\nproviso that the data might not be correct, and users will still find it\nuseful.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"}]}