{"thread":{"id":"52259","subject":"Feature Request: Check if commit is existent via http-protocol","startedAt":"2019-11-13T13:14:09Z","lastAt":"2019-11-14T20:05:58Z","messageCount":4,"participants":["Marius Raht","brian m. carlson","Jeff King","Jonathan Tan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"386121","messageId":"c5147250-4af2-0e98-db6e-20602a38fba4@gmail.com","threadId":"52259","inReplyTo":null,"subject":"Feature Request: Check if commit is existent via http-protocol","fromName":"Marius Raht","fromEmail":"mariusraht@gmail.com","sentAt":"2019-11-13T13:14:00Z","receivedAt":"2019-11-13T13:14:09Z","isPatch":false,"sender":{"key":"mariusraht@gmail.com","avatar":null},"body":"Hi there,\n\nfor the development of a git client on a SAP System we need to make sure \nthat a specific commit is existent in a specific branch. For that we \nhave to ask the git server for the related information via the http \nprotocol. There are two option from my point of view to achieve this:\n\n1) You can request a specific list of commits of a branch by index (e.g. \n\"1 to 30 <sha1 of branch>\" would send the first 30 commits from the \nserver to the client of the branch \"master\"\n2) You send a request to the git server to verify that a specific commit \nis within a specific branch´and the response is something like \"TRUE\" or \nthe sha1 of the branch the commit belongs to (branch of the time the \ncommit was created).\n\nBest regards,\n\nMarius Raht\n\n"},{"id":"386158","messageId":"20191114025244.GC9216@camp.crustytoothpaste.net","threadId":"52259","inReplyTo":"c5147250-4af2-0e98-db6e-20602a38fba4@gmail.com","subject":"Re: Feature Request: Check if commit is existent via http-protocol","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-11-14T02:52:44Z","receivedAt":"2019-11-14T02:52:52Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-11-13 at 13:14:00, Marius Raht wrote:\n> Hi there,\n> \n> for the development of a git client on a SAP System we need to make sure\n> that a specific commit is existent in a specific branch. For that we have to\n> ask the git server for the related information via the http protocol. There\n> are two option from my point of view to achieve this:\n> \n> 1) You can request a specific list of commits of a branch by index (e.g. \"1\n> to 30 <sha1 of branch>\" would send the first 30 commits from the server to\n> the client of the branch \"master\"\n> 2) You send a request to the git server to verify that a specific commit is\n> within a specific branch´and the response is something like \"TRUE\" or the\n> sha1 of the branch the commit belongs to (branch of the time the commit was\n> created).\n\nI think there may be a misunderstanding of the design of the Git HTTP\nprotocol.  It's essentially a stateless version of the regular Git\nprotocol which provides data transport (and as a side effect, ref\ndiscovery).  It isn't designed to be an API that can be queried\nremotely, and so it intentionally supports an extremely limited set of\nfunctionality.\n\nGit supports a massive number of ways to query data, and there's just no\nway to efficiently and securely support all of those methods natively\nover an API.  In fact, some operations Git can perform are potentially\nexpensive, and exposing an API to perform those is a security problem\n(due to DoS attacks).\n\nSome of that functionality is available in various Git hosting solutions\nthrough their own APIs, but as far as I'm aware, there aren't any which\nperform this operation (which is essentially \"git merge-base\n--is-ancestor\").  If you want this functionality in a particular\nplatform, I'd encourage you to reach out to the provider of that\nplatform to ask them if they'd implement it.  However, I don't think\nwe're likely to implement it in Git's HTTP protocol.\n\nOther contributors are welcome to chime in if anything I said seems\nincorrect or off base.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"386171","messageId":"20191114064137.GF10643@sigill.intra.peff.net","threadId":"52259","inReplyTo":"20191114025244.GC9216@camp.crustytoothpaste.net","subject":"Re: Feature Request: Check if commit is existent via http-protocol","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-11-14T06:41:37Z","receivedAt":"2019-11-14T06:41:39Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 14, 2019 at 02:52:44AM +0000, brian m. carlson wrote:\n\n> Git supports a massive number of ways to query data, and there's just no\n> way to efficiently and securely support all of those methods natively\n> over an API.  In fact, some operations Git can perform are potentially\n> expensive, and exposing an API to perform those is a security problem\n> (due to DoS attacks).\n> \n> Some of that functionality is available in various Git hosting solutions\n> through their own APIs, but as far as I'm aware, there aren't any which\n> perform this operation (which is essentially \"git merge-base\n> --is-ancestor\").  If you want this functionality in a particular\n> platform, I'd encourage you to reach out to the provider of that\n> platform to ask them if they'd implement it.  However, I don't think\n> we're likely to implement it in Git's HTTP protocol.\n> \n> Other contributors are welcome to chime in if anything I said seems\n> incorrect or off base.\n\nI think that's all accurate.\n\nThere's nothing to say we _couldn't_ provide a richer set of commands\nvia Git's protocol. There are already uncommon ones like upload-archive.\nAnd people have talked about being able to offload git-grep requests to\na server.\n\nBut it really opens a can of worms in terms of which operations to\nsupport, how to handle load, etc. The strategy so far for Git itself has\nbeen to keep servers relatively dumb, and clients interested in doing\nqueries should clone and then do what they want locally. That's not the\nmost efficient thing for clients that want to do one-off queries, but it\nkeeps the boundaries clean. Even if we did implement more server-side\noperations, they'd almost certainly be disabled by default.\n\n-Peff\n"},{"id":"386199","messageId":"20191114200553.166098-1-jonathantanmy@google.com","threadId":"52259","inReplyTo":"c5147250-4af2-0e98-db6e-20602a38fba4@gmail.com","subject":"Re: Feature Request: Check if commit is existent via http-protocol","fromName":"Jonathan Tan","fromEmail":"jonathantanmy@google.com","sentAt":"2019-11-14T20:05:53Z","receivedAt":"2019-11-14T20:05:58Z","isPatch":false,"sender":{"key":"jonathantanmy@fastmail.com","avatar":null},"body":"> 1) You can request a specific list of commits of a branch by index (e.g. \n> \"1 to 30 <sha1 of branch>\" would send the first 30 commits from the \n> server to the client of the branch \"master\"\n\nIf your Git server supports it, a partial solution is to do a partial\nclone, e.g.:\n\n  git clone --filter=tree:0 --bare \\\n    https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux\n\nAnd you can add --depth=10 if you want the last 10 commits in that\nbranch too:\n\n  git clone --filter=tree:0 --bare --depth=10 \\\n    https://kernel.googlesource.com/pub/scm/linux/kernel/git/torvalds/linux\n\nThis creates a partial clone with no local trees or blobs. If you're\njust doing ancestry checks with \"git merge-base\", that should be\nsufficient. (If you're doing anything else, trees and blobs will be\ndownloaded as Git needs them.)\n"}]}