From: Phillip Wood Date: Tue, 17 Aug 2021 10:09:40 GMT Subject: Re: [PATCH v3] [GSOC] cherry-pick: use better advice message Message-ID: In-Reply-To: On 13/08/2021 21:14, Junio C Hamano wrote: > Phillip Wood writes: > >>> +++ 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 ' or 'git rm ' >>> - hint: and commit the result with 'git commit' >>> + hint: Resolve all conflicts manually, mark them as resolved with >>> + hint: \"git add/rm \", 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. Good point, you're right I had completely missed that, thanks for pointing it out Phillip > > 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 ${SQ} or ${SQ}git rm ${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 ", 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. >