{"thread":{"id":"52258","subject":"Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely","startedAt":"2019-11-13T01:01:11Z","lastAt":"2019-11-19T23:46:08Z","messageCount":4,"participants":["Force.Charlie","Junio C Hamano","Denton Liu"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"386073","messageId":"tencent_AB1A7466D1F2EF9A84B437705F06A7652709@qq.com","threadId":"52258","inReplyTo":null,"subject":"Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely","fromName":"Force.Charlie","fromEmail":"force@forcemz.net","sentAt":"2019-11-13T01:00:52Z","receivedAt":"2019-11-13T01:01:11Z","isPatch":false,"sender":{"key":"force@forcemz.net","avatar":null},"body":"Recently, when I tested my Git Over HTTP server, I found a bug in Git. When we used git -c protocol.version=2 clone --shallow-since , if the time format is wrong, it will cause git to wait indefinitely.\n\nGithub supports Wire Protocol to reproduce, Gitlab does not support it and does not reproduce it.\n\nThe commands that can be retried are as follows:\n\n```shell\n# time format wrong\ngit -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n# trace\nGIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n```\nWe can see that the server closes the HTTP connection after sending the `shallow-info\\n` message, and git-remote-http(s) is still waiting.\n\n```\n$ git --version --build-options\ngit version 2.24.0\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\n\n```\n\nWhen the time format is correct, the clone is successful, so this is followed by the shallow-list：\n\n```shell\nGIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=2015-10-12\n```\n\nGithub Issues: https://github.com/gitgitgadget/git/issues/457"},{"id":"386089","messageId":"xmqqpnhwbfx7.fsf@gitster-ct.c.googlers.com","threadId":"52258","inReplyTo":"tencent_AB1A7466D1F2EF9A84B437705F06A7652709@qq.com","subject":"Re: Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-11-13T03:42:28Z","receivedAt":"2019-11-13T03:42:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Force.Charlie\" <force@forcemz.net> writes:\n\n> # time format wrong\n> git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n\nThat's the valid/right way to specify the timestamp that is\n20,151,012 seconds after the epoch (i.e. 1970-01-01), isn't it?\n\n\n\n"},{"id":"386567","messageId":"20191119233645.GA99848@generichostname","threadId":"52258","inReplyTo":"xmqqpnhwbfx7.fsf@gitster-ct.c.googlers.com","subject":"Re: Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T23:36:45Z","receivedAt":"2019-11-19T23:36:51Z","isPatch":false,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"Hi Junio,\n\nOn Wed, Nov 13, 2019 at 12:42:28PM +0900, Junio C Hamano wrote:\n> \"Force.Charlie\" <force@forcemz.net> writes:\n> \n> > # time format wrong\n> > git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n> \n> That's the valid/right way to specify the timestamp that is\n> 20,151,012 seconds after the epoch (i.e. 1970-01-01), isn't it?\n\nI don't think so. When we run the same thing under protocol v1, we get\nthe following:\n\n\t$ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012\n\tCloning into 'git'...\n\tfatal: the remote end hung up unexpectedly\n\neven though the following does work:\n\n\t$ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=2015-10-12\n\tCloning into 'git'...\n\tremote: Enumerating objects: 93982, done.\n\t...\n\nwhich suggests to me that the non-dashed form is invalid.\n\nThanks,\n\nDenton\n"},{"id":"386568","messageId":"20191119234603.GA50851@generichostname","threadId":"52258","inReplyTo":"tencent_AB1A7466D1F2EF9A84B437705F06A7652709@qq.com","subject":"Re: Protocol v2: The wrong --shallow-since time format causes git to wait indefinitely","fromName":"Denton Liu","fromEmail":"liu.denton@gmail.com","sentAt":"2019-11-19T23:46:03Z","receivedAt":"2019-11-19T23:46:08Z","isPatch":false,"sender":{"key":"liu.denton@gmail.com","avatar":"https://avatars.githubusercontent.com/u/9620836?v=4"},"body":"On Wed, Nov 13, 2019 at 09:00:52AM +0800, Force.Charlie wrote:\n> Recently, when I tested my Git Over HTTP server, I found a bug in Git. When we used git -c protocol.version=2 clone --shallow-since , if the time format is wrong, it will cause git to wait indefinitely.\n> \n> Github supports Wire Protocol to reproduce, Gitlab does not support it and does not reproduce it.\n> \n> The commands that can be retried are as follows:\n> \n> ```shell\n> # time format wrong\n> git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n> # trace\n> GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012\n> ```\n> We can see that the server closes the HTTP connection after sending the `shallow-info\\n` message, and git-remote-http(s) is still waiting.\n> \n> ```\n> $ git --version --build-options\n> git version 2.24.0\n> cpu: x86_64\n> no commit associated with this build\n> sizeof-long: 8\n> sizeof-size_t: 8\n> \n> ```\n> \n> When the time format is correct, the clone is successful, so this is followed by the shallow-list：\n> \n> ```shell\n> GIT_TRACE=1 GIT_CURL_VERBOSE=1 GIT_TRACE_PACKET=2 git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=2015-10-12\n> ```\n> \n> Github Issues: https://github.com/gitgitgadget/git/issues/457\n\nFWIW, I can reproduce this issue as well. From what I can tell (without\nactually looking at any code), it seems like when an invalid\n`--shallow-since` is given to the server, it'll hang up on the client.\n\nWith protocol v1, the client quits as expected:\n\n\t$ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012\n\tCloning into 'git'...\n\tfatal: the remote end hung up unexpectedly\n\nHowever, with v2, I believe that the client doesn't detect the hang up\nand just waits forever.\n\nUnfortunately, I don't know the networking code at all and I don't have\ntime to actually dig into the code. Hopefully this helps a little bit,\nthough.\n\nThanks,\n\nDenton\n"}]}