Re: [PATCH v2 3/5] t4301: verify that merge-tree fails on missing blob objects
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 8, 2024, 00:52 UTC
- Message-ID
- <CAPig+cQx1=wM7v0cCuVwNwhd3Zsh0fZgZ1A-vX--uy0dd1+kDg@mail.gmail.com>
- In-Reply-To
- <CAPig+cSJz3U+vT==NhX5hcrTjsCggnAzhzQOvZcSXbcEGuYaKQ@mail.gmail.com>
On Wed, Feb 7, 2024 at 12:24 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 13 quoted lines
> Interpolating the $seqN variable directly into the string rather than > using %s would make it even clearer that only a single line is being > generated as input to git-mktree: > > tree1=$(printf "100644 blob $seq1\tsequence\n" | git mktree) && > tree2=$(printf "100644 blob $seq2\tsequence\n" | git mktree) && > tree3=$(printf "100644 blob $seq3\tsequence\n" | git mktree) && > > Alternatively `echo` could be used, though it's not necessarily any nicer: > > tree1=$(echo "100644 blob $seq1Qsequence" | q_to_tab | git mktree) && > tree2=$(echo "100644 blob $seq2Qsequence" | q_to_tab | git mktree) && > tree3=$(echo "100644 blob $seq3Qsequence" | q_to_tab | git mktree) &&
The `printf` example is probably cleaner, thus preferable. For completeness, though, I should mention that the `echo` example is, of course, not quite correct. For the interpolation to work as intended, it would need ${...}:
tree1=$(echo "100644 blob ${seq1}Qsequence" | q_to_tab | git mktree) &&
tree2=$(echo "100644 blob ${seq2}Qsequence" | q_to_tab | git mktree) &&
tree3=$(echo "100644 blob ${seq3}Qsequence" | q_to_tab | git mktree) &&