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

Re: [PATCH v3] [GSOC] cherry-pick: use better advice message

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 13, 2021, 20:14 UTC
Message-ID
<xmqqzgtlumob.fsf@gitster.g>
In-Reply-To
<a510722c-d5a2-f00c-dd20-dd7f76da2408@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
Show 18 quoted lines
>> +++ b/t/t3507-cherry-pick-conflict.sh
>> @@ -53,9 +53,12 @@ test_expect_success 'advice from failed cherry-pick' "
>>   	picked=\$(git rev-parse --short picked) &&
>>   	cat <<-EOF >expected &&
>
> If you quote the here doc end marker then there is no substitution in
> the here doc so writing
>
> 	cat <<-\EOF >expected &&
>
>>   	error: could not apply \$picked... picked
>> -	hint: after resolving the conflicts, mark the corrected paths
>> -	hint: with 'git add <paths>' or 'git rm <paths>'
>> -	hint: and commit the result with 'git commit'
>> +	hint: Resolve all conflicts manually, mark them as resolved with
>> +	hint: \"git add/rm <conflicted_files>\", then run
>
> means you can replace \" with " here

Hmph, actually the double-quote that opens the body of test_expect_success should be stared at with a very cautious eyes, as they often do not mean what the author of the patch thought they do. I can see that it already fooled your eyes into thinking that there is no substitution, but $picked needs to be substituted into its value. The backslash before it is *not* about guarding it from substitution inside here-doc; it is to pass literal "$" into the string, which is the last parameter to test_expect_success, that gets eval'ed.

The original of this one, for example, would probably have been better if written like so:

test_expect_success 'advice from failed cherry-pick' '
	pristine_detach initial &&
	SQ='\'' &&
	picked=$(git rev-parse --short picked) &&
	cat <<-EOF >expected &&
	error: could not apply $picked... picked
	hint: after resolving the conflicts, mark the corrected paths
	hint: with ${SQ}git add <paths>${SQ} or ${SQ}git rm <paths>${SQ}
	hint: and commit the result with ${SQ}git commit${SQ}
	EOF
	test_must_fail git cherry-pick picked 2>actual &&
	test_cmp expected actual
'

And because there is no single quote in the updated text, it would become:

test_expect_success 'advice from failed cherry-pick' '
	pristine_detach initial &&
	picked=$(git rev-parse --short picked) &&
	cat <<-EOF >expected &&
	error: could not apply $picked... picked
	hint: Resolve all conflicts manually, mark them as resolved with
	hint: "git add/rm <conflicted_files>", then run
	EOF
	test_must_fail git cherry-pick picked 2>actual &&
	test_cmp expected actual
'

which makes it far easier to see that $picked needs to be substituted, and the "git add/rm" are to be enclosed in dq pair.

Previous: ZheNing HuNext: ZheNing Hu
Message 19 of 32 in “[GSOC] cherry-pick: fix bug when used with GIT_CHERRY_PICK_HELP”
  1. 0/2 [GSOC] cherry-pick: fix bug when used with GIT_CHERRY_PICK_HELPZheNing Hu via GitGitGadget, Jul 31, 2021
  2. 2/2 [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Jul 31, 2021
  3. Phillip WoodAug 1, 2021
  4. ZheNing HuAug 2, 2021
  5. 1/2 [GSOC] cherry-pick: fix bug when used with GIT_CHERRY_PICK_HELPZheNing Hu via GitGitGadget, Jul 31, 2021
  6. Phillip WoodAug 1, 2021
  7. ZheNing HuAug 2, 2021
  8. 0/2 [GSOC] cherry-pick: fix bug when used with GIT_CHERRY_PICK_HELPZheNing Hu via GitGitGadget, Aug 3, 2021
  9. 1/2 [GSOC] cherry-pick: fix bug when used with GIT_CHERRY_PICK_HELPZheNing Hu via GitGitGadget, Aug 3, 2021
  10. Junio C HamanoAug 3, 2021
  11. ZheNing HuAug 4, 2021
  12. Phillip WoodAug 4, 2021
  13. Junio C HamanoAug 4, 2021
  14. ZheNing HuAug 5, 2021
  15. 2/2 [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 3, 2021
  16. [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 5, 2021
  17. Phillip WoodAug 11, 2021
  18. ZheNing HuAug 13, 2021
  19. Junio C HamanoAug 13, 2021
  20. ZheNing HuAug 14, 2021
  21. Phillip WoodAug 17, 2021
  22. [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 14, 2021
  23. Junio C HamanoAug 14, 2021
  24. ZheNing HuAug 15, 2021
  25. [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 16, 2021
  26. Phillip WoodAug 18, 2021
  27. ZheNing HuAug 19, 2021
  28. ZheNing HuAug 19, 2021
  29. [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 19, 2021
  30. Junio C HamanoAug 19, 2021
  31. ZheNing HuAug 21, 2021
  32. [GSOC] cherry-pick: use better advice messageZheNing Hu via GitGitGadget, Aug 22, 2021

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.