git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] t/check-non-portable-shell: detect "FOO= shell_func", too

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Dec 26, 2019, 22:37 UTC
Message-ID
<20191226223727.GB186931@google.com>
In-Reply-To
<xmqq7e2ilu1j.fsf@gitster-ct.c.googlers.com>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 15 quoted lines
>> Just like assigning a nonempty value, assigning an empty value to a
>> shell variable when calling a function produces non-portable behavior:
>> in some shells, the assignment lasts for the duration of the function
>> invocation, and in others, it persists after the function returns.
>>
>> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
>> ---
>> If it would be useful for me to send a copy of the "Enable protocol v2
>> by default" series rebased on top of this, let me know.
>
> When rebased, t5552 passes (including the test lint) at the "request
> v0 explicitly for some tests" step now.
>
> The tip of "promote proto v2 to default" series fails at 5552.5
> with or without these two patches, though.

Oh, subtle. With shells that leak variable assignments after a function returns (such as bash when run as 'sh'), 5552.5 was running with GIT_TEST_PROTOCOL_VERSION=0, masking the issue.

In protocol v2, there is no "stateful" mode: negotiation always uses the stateless-rpc path, and the stateless-rpc path involves more care to avoid chatter during negotiation (since request size increases with each round).

This is why b1.c14 and b1.c9 don't show up in the v2 trace. Processing the trace with "git name-rev --stdin" yields

 packet:        fetch> want 184bd23dc533e1e63153e7e181411bd29acca918
 packet:        fetch> have f65fc9b4d5c1cb76494a7f8df0230d8d29a33e67 (tags/b8.c19)
 packet:        fetch> have 334d40a157dec5d93023976c30cd22b24bdc279a (tags/b7.c19)
[...]
 packet:        fetch> have e3496f08debed7528bd7e4c4a12b71d1a99d697f (tags/b1.c19)
 packet:        fetch> have e7bb01cb25bebd0341c9d62f4c7e929a99b6ed4b (tags/b8.c17)
 packet:        fetch> have 7f5656e94770d527d4f909fd5e2ea274ec63177a (tags/b7.c17)
[...]
 packet:        fetch> have 17639a004fe8511fe1de57dd9ddabf2ee0de902d (tags/b1.c17)
 packet:        fetch> 0000
 packet:        fetch< acknowledgments
 packet:        fetch< ACK e3496f08debed7528bd7e4c4a12b71d1a99d697f (tags/b1.c19)
 packet:        fetch< ACK 17639a004fe8511fe1de57dd9ddabf2ee0de902d (tags/b1.c17)

By comparison, with protocol v0 over stateful bidirectional transports, there's an additional round-trip folded in:

 packet:        fetch> have f65fc9b4d5c1cb76494a7f8df0230d8d29a33e67 (tags/b8.c19)
 packet:        fetch> have 334d40a157dec5d93023976c30cd22b24bdc279a (tags/b7.c19)
[...]
 packet:        fetch> have e3496f08debed7528bd7e4c4a12b71d1a99d697f (tags/b1.c19)
 packet:        fetch> have e7bb01cb25bebd0341c9d62f4c7e929a99b6ed4b (tags/b8.c17)
 packet:        fetch> have 7f5656e94770d527d4f909fd5e2ea274ec63177a (tags/b7.c17)
[...]
 packet:        fetch> have 17639a004fe8511fe1de57dd9ddabf2ee0de902d (tags/b1.c17)
 packet:        fetch> 0000
 packet:        fetch> have a1d75daa2f482f89171f092778da506803e54531 (tags/b8.c14)
 packet:        fetch> have b2e9b68d2650b77283421888be8a950c18bab29d (tags/b7.c14)
[...]
 packet:        fetch> have b89f6499d7cee40ef422edb15433a10f82de0206 (tags/b1.c14)
 packet:        fetch> have e4190b433240834c895347214d29426a094f2fe2 (tags/b8.c9)
 packet:        fetch> have 5f1aa7f016defcf74e5e1d4991342987c9d4b447 (tags/b7.c9)
[...]
 packet:        fetch> have b76868e654ce45adb9e06f638e48a72556843361 (tags/b1.c9)
 packet:        fetch> 0000
 packet:        fetch< ACK e3496f08debed7528bd7e4c4a12b71d1a99d697f (tags/b1.c19) common
 packet:        fetch< ACK 17639a004fe8511fe1de57dd9ddabf2ee0de902d (tags/b1.c17) common
Patch coming in a moment to force v0 here with a comment.

Thanks, Jonathan

Previous: Junio C HamanoNext: Jonathan Nieder
Message 12 of 17 in “Enable protocol v2 by default”
  1. 0/5 Enable protocol v2 by defaultJonathan Nieder, Dec 24, 2019
  2. 1/5 fetch test: use more robust test for filtered objectsJonathan Nieder, Dec 24, 2019
  3. Derrick StoleeDec 26, 2019
  4. 2/5 config doc: protocol.version is not experimentalJonathan Nieder, Dec 24, 2019
  5. 3/5 test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriateJonathan Nieder, Dec 24, 2019
  6. Junio C HamanoDec 26, 2019
  7. 0/2 avoid use of "VAR= cmd" with a shell function (Re: [PATCH 3/5] test: request GIT_TEST_PROTOCOL_VERSION=0 when appropriate)Jonathan Nieder, Dec 26, 2019
  8. 1/2 fetch test: avoid use of "VAR= cmd" with a shell functionJonathan Nieder, Dec 26, 2019
  9. 2/2 t/check-non-portable-shell: detect "FOO= shell_func", tooJonathan Nieder, Dec 26, 2019
  10. Junio C HamanoDec 26, 2019
  11. Junio C HamanoDec 26, 2019
  12. Jonathan NiederDec 26, 2019
  13. fetch test: mark test of "skipping" haves as v0-onlyJonathan Nieder, Dec 26, 2019
  14. Eric SunshineDec 26, 2019
  15. 4/5 protocol test: let protocol.version override GIT_TEST_PROTOCOL_VERSIONJonathan Nieder, Dec 24, 2019
  16. 5/5 fetch: default to protocol version 2Jonathan Nieder, Dec 24, 2019
  17. Derrick StoleeDec 26, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.