{"thread":{"id":"56765","subject":"Git silently broke push-options over ssh?","startedAt":"2021-10-22T17:34:15Z","lastAt":"2021-10-23T14:58:05Z","messageCount":3,"participants":["Sven Strickroth","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"439394","messageId":"4aef40f2-43f8-eab3-a840-6e76c8b4afbb@cs-ware.de","threadId":"56765","inReplyTo":null,"subject":"Git silently broke push-options over ssh?","fromName":"Sven Strickroth","fromEmail":"sven@cs-ware.de","sentAt":"2021-10-22T17:27:14Z","receivedAt":"2021-10-22T17:34:15Z","isPatch":false,"sender":{"key":"sven@cs-ware.de","avatar":null},"body":"Hi,\n\nI'm using Git (for Windows) 2.33.1 and using push-options as described \non <https://docs.gitlab.com/ee/user/project/push_options.html> does not \nwork any more (IIRC it used to work with Git 2.16 and 2.17).\n\nIf I understood \n<https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html> \ncorrectly I have to enable the Git protocol version 2 and then the push \noptions should work.\n\nNow, when I try to use push options on Windows it does not work. I tried \nto debug it:\n\nD:\\TortoiseGit>set GIT_TRACE=2\nD:\\TortoiseGit>set GIT_SSH=ssh.exe\nD:\\TortoiseGit>set GIT_SSH_VARIANT=ssh\nD:\\TortoiseGit>set GIT_PROTOCOL=version=2\nD:\\TortoiseGit>git -c protocol.version=2 -c ssh.variant=ssh -c \nssh.command=ssh push -v -o ci.skip origin master~23:testing\n17:36:06.285346 exec-cmd.c:237          trace: resolved executable dir: \nC:/Program Files/Git/mingw64/bin\n17:36:06.285346 git.c:455               trace: built-in: git push -v -o \nci.skip origin 'master~23:testing'\nPushing to gitlab.com:tortoisegit/tortoisegit.git\n17:36:06.295270 run-command.c:666       trace: run_command: unset \nGIT_CONFIG_PARAMETERS GIT_PREFIX; ssh.exe git@gitlab.com \n'git-receive-pack '\\''tortoisegit/tortoisegit.git'\\'''\n\nAs you can see, the \"-o SendEnv\" parameter not passed to ssh.exe and, \ntherefore, I think the push option is not transferred to the server.\n\nAccording to <https://github.com/git-for-windows/git/issues/3486> the \nreason is a commit that was shipped with Git 2.18 (in 2018):\n\n<https://github.com/git/git/commit/1aa8dded3afff28d8f4c24a97b237a0d9e633173>\n\nHow to use push options with Git over SSH?\n\n-- \nBest regards,\n  Sven Strickroth\n  PGP key id F5A9D4C4 @ any key-server\n"},{"id":"439419","messageId":"YXMku8V9cdHLfXt6@coredump.intra.peff.net","threadId":"56765","inReplyTo":"4aef40f2-43f8-eab3-a840-6e76c8b4afbb@cs-ware.de","subject":"Re: Git silently broke push-options over ssh?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2021-10-22T20:53:15Z","receivedAt":"2021-10-22T20:53:20Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Fri, Oct 22, 2021 at 07:27:14PM +0200, Sven Strickroth wrote:\n\n> If I understood <https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html>\n> correctly I have to enable the Git protocol version 2 and then the push\n> options should work.\n\nI don't think that is true. There is no v2 push protocol yet, so the\npush options must work over v0.\n\n> Now, when I try to use push options on Windows it does not work. I tried to\n> debug it:\n> \n> D:\\TortoiseGit>set GIT_TRACE=2\n> D:\\TortoiseGit>set GIT_SSH=ssh.exe\n> D:\\TortoiseGit>set GIT_SSH_VARIANT=ssh\n> D:\\TortoiseGit>set GIT_PROTOCOL=version=2\n> D:\\TortoiseGit>git -c protocol.version=2 -c ssh.variant=ssh -c\n> ssh.command=ssh push -v -o ci.skip origin master~23:testing\n> 17:36:06.285346 exec-cmd.c:237          trace: resolved executable dir:\n> C:/Program Files/Git/mingw64/bin\n> 17:36:06.285346 git.c:455               trace: built-in: git push -v -o\n> ci.skip origin 'master~23:testing'\n> Pushing to gitlab.com:tortoisegit/tortoisegit.git\n> 17:36:06.295270 run-command.c:666       trace: run_command: unset\n> GIT_CONFIG_PARAMETERS GIT_PREFIX; ssh.exe git@gitlab.com 'git-receive-pack\n> '\\''tortoisegit/tortoisegit.git'\\'''\n> \n> As you can see, the \"-o SendEnv\" parameter not passed to ssh.exe and,\n> therefore, I think the push option is not transferred to the server.\n\nPush options don't go through the environment. The GIT_PROTOCOL magic\nfor enabling v2 does, but push options themselves happen over the Git\nprotocol. Try GIT_TRACE_PACKET for seeing the actual conversation. E.g.:\n\n  $ GIT_TRACE_PACKET=1 GIT_TRACE=1 git push -o foo git.peff.net:foo.git\n  16:49:19.236448 git.c:455               trace: built-in: git push -o foo git.peff.net:foo.git\n  16:49:19.237409 run-command.c:666       trace: run_command: unset GIT_PREFIX; ssh git.peff.net 'git-receive-pack '\\''foo.git'\\'''\n  16:49:19.423323 pkt-line.c:80           packet:         push< b2f0a7f47f5f2aebe1e7fceff19a57de20a78c06 refs/heads/master\\0report-status report-status-v2 delete-refs side-band-64k quiet atomic ofs-delta push-options object-format=sha1 agent=git/2.30.2\n  16:49:19.423399 pkt-line.c:80           packet:         push< 0000\n  16:49:19.431385 pkt-line.c:80           packet:         push> 0000\n  16:49:19.431421 pkt-line.c:80           packet:         push> foo\n  16:49:19.431442 pkt-line.c:80           packet:         push> 0000\n  Everything up-to-date\n\nOn the server side, receive-pack will stick them in the environment to\ncommunicate them to hooks, etc, but you wouldn't be able to see that\nfrom the client.\n\nDo note that I had to set receive.advertisePushOptions on the server to\nmake it work (though if it's not set, the client should complain\nloudly). If you're pushing to gitlab.com they've presumably set up the\nserver side appropriately.\n\n-Peff\n"},{"id":"439450","messageId":"ff7ff6ca-2941-c61e-f36d-0732b367fc64@cs-ware.de","threadId":"56765","inReplyTo":"YXMku8V9cdHLfXt6@coredump.intra.peff.net","subject":"Re: Git silently broke push-options over ssh?","fromName":"Sven Strickroth","fromEmail":"email@cs-ware.de","sentAt":"2021-10-23T14:57:59Z","receivedAt":"2021-10-23T14:58:05Z","isPatch":false,"sender":{"key":"email@cs-ware.de","avatar":"https://avatars.githubusercontent.com/u/428133?v=4"},"body":"Am 22.10.2021 um 22:53 schrieb Jeff King:\n> On Fri, Oct 22, 2021 at 07:27:14PM +0200, Sven Strickroth wrote:\n> \n>> If I understood <https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html>\n>> correctly I have to enable the Git protocol version 2 and then the push\n>> options should work.\n> \n> I don't think that is true. There is no v2 push protocol yet, so the\n> push options must work over v0.\n\nYou are right. After enabling GIT_TRACE_PACKET I see that the \npush-option gets transmitted correctly.\n\nI got confused was because a GitLab CI pipeline run despite I passed \nci.skip. The reason why the pipeline ran despite of that flag is that \nsome external push hook triggered a CI pipeline action manually - when I \nlook at GitLab immediately after the push I see that the pipeline is \nskipped and then the external hook fires...\n\nThanks for the hint for enabling GIT_TRACE_PACKET  Peff and sorry for \nthe noise.\n\n  Sven\n"}]}