Hi Eric, On Wed, 7 Feb 2024, Eric Sunshine wrote: > On Wed, Feb 7, 2024 at 11:48 AM Johannes Schindelin via GitGitGadget > <gitgitgadget@xxxxxxxxx> wrote: > > We just fixed a problem where `merge-tree` would not fail on missing > > tree objects. Let's ensure that that problem does not occur with blob > > objects (and won't, in the future, either). > > > > Signed-off-by: Johannes Schindelin <johannes.schindelin@xxxxxx> > > --- > > diff --git a/t/t4301-merge-tree-write-tree.sh b/t/t4301-merge-tree-write-tree.sh > > @@ -961,4 +961,18 @@ test_expect_success 'error out on missing tree objects' ' > > +test_expect_success 'error out on missing blob objects' ' > > + seq1=$(test_seq 1 10 | git hash-object -w --stdin) && > > + seq2=$(test_seq 1 11 | git hash-object -w --stdin) && > > + seq3=$(test_seq 0 10 | git hash-object -w --stdin) && > > Is there significance to the ranges passed to test_seq()? Originally, there was, since I wanted the merge to succeed without conflicts. However, I simplified the test case similar to what you suggested and now specifically verify that the expected error message is shown (as opposed to, say, an error message indicating a merge conflict). > Or, can the same be achieved by using arbitrary content for each blob? > > blob1=$(echo "one" | git hash-object -w --stdin) && > blob2=$(echo "two" | git hash-object -w --stdin) && > blob3=$(echo "three" | git hash-object -w --stdin) && > > > + tree1=$(printf "100644 blob %s\tsequence" $seq1 | git mktree) && > > + tree2=$(printf "100644 blob %s\tsequence" $seq2 | git mktree) && > > + tree3=$(printf "100644 blob %s\tsequence" $seq3 | git mktree) && > > I found the lack of terminating "\n" in the `printf` confusing, > especially since the variable names (seq1, seq2, etc.) and the use of > `printf` seem to imply, at first glance, that each git-mktree > invocation is receiving multiple lines as input which, it turns out, > is not the case. Adding the missing "\n" would help: > > tree1=$(printf "100644 blob %s\tsequence\n" $seq1 | git mktree) && > tree2=$(printf "100644 blob %s\tsequence\n" $seq2 | git mktree) && > tree3=$(printf "100644 blob %s\tsequence\n" $seq3 | git mktree) && I added the `\n` and now avoid the `%s`. Thank you for your review! Johannes > > 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) && > > > + git init --bare missing-blob.git && > > + test_write_lines $seq1 $seq3 $tree1 $tree2 $tree3 | > > + git pack-objects missing-blob.git/objects/pack/side1-whatever-is-missing && > > + test_must_fail git --git-dir=missing-blob.git merge-tree --merge-base=$tree1 $tree2 $tree3 >actual && > > + test_must_be_empty actual > > +' >