Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t4054-diff-bogus-tree.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t4054-diff-bogus-tree.sh` 83 lines ยท 2371 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='test diff with a bogus tree containing the null sha1' 4 5 . ./test-lib.sh 6 7 test_expect_success 'create bogus tree' ' 8 name=$(echo $ZERO_OID | sed -e "s/00/Q/g") && 9 bogus_tree=$( 10 printf "100644 fooQ$name" | 11 q_to_nul | 12 git hash-object --literally -w --stdin -t tree 13 ) 14 ' 15 16 test_expect_success 'create tree with matching file' ' 17 echo bar >foo && 18 git add foo && 19 good_tree=$(git write-tree) && 20 blob=$(git rev-parse :foo) 21 ' 22 23 test_expect_success 'raw diff shows null sha1 (addition)' ' 24 echo ":000000 100644 $ZERO_OID $ZERO_OID A foo" >expect && 25 git diff-tree $EMPTY_TREE $bogus_tree >actual && 26 test_cmp expect actual 27 ' 28 29 test_expect_success 'raw diff shows null sha1 (removal)' ' 30 echo ":100644 000000 $ZERO_OID $ZERO_OID D foo" >expect && 31 git diff-tree $bogus_tree $EMPTY_TREE >actual && 32 test_cmp expect actual 33 ' 34 35 test_expect_success 'raw diff shows null sha1 (modification)' ' 36 echo ":100644 100644 $blob $ZERO_OID M foo" >expect && 37 git diff-tree $good_tree $bogus_tree >actual && 38 test_cmp expect actual 39 ' 40 41 test_expect_success 'raw diff shows null sha1 (other direction)' ' 42 echo ":100644 100644 $ZERO_OID $blob M foo" >expect && 43 git diff-tree $bogus_tree $good_tree >actual && 44 test_cmp expect actual 45 ' 46 47 test_expect_success 'raw diff shows null sha1 (reverse)' ' 48 echo ":100644 100644 $ZERO_OID $blob M foo" >expect && 49 git diff-tree -R $good_tree $bogus_tree >actual && 50 test_cmp expect actual 51 ' 52 53 test_expect_success 'raw diff shows null sha1 (index)' ' 54 echo ":100644 100644 $ZERO_OID $blob M foo" >expect && 55 git diff-index $bogus_tree >actual && 56 test_cmp expect actual 57 ' 58 59 test_expect_success 'patch fails due to bogus sha1 (addition)' ' 60 test_must_fail git diff-tree -p $EMPTY_TREE $bogus_tree 61 ' 62 63 test_expect_success 'patch fails due to bogus sha1 (removal)' ' 64 test_must_fail git diff-tree -p $bogus_tree $EMPTY_TREE 65 ' 66 67 test_expect_success 'patch fails due to bogus sha1 (modification)' ' 68 test_must_fail git diff-tree -p $good_tree $bogus_tree 69 ' 70 71 test_expect_success 'patch fails due to bogus sha1 (other direction)' ' 72 test_must_fail git diff-tree -p $bogus_tree $good_tree 73 ' 74 75 test_expect_success 'patch fails due to bogus sha1 (reverse)' ' 76 test_must_fail git diff-tree -R -p $good_tree $bogus_tree 77 ' 78 79 test_expect_success 'patch fails due to bogus sha1 (index)' ' 80 test_must_fail git diff-index -p $bogus_tree 81 ' 82 83 test_done