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/t6301-for-each-ref-errors.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 / t6301-for-each-ref-errors.sh` 91 lines ยท 2857 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='for-each-ref errors for broken refs' 4 5 . ./test-lib.sh 6 7 ZEROS=$ZERO_OID 8 9 test_expect_success setup ' 10 MISSING=$(test_oid deadbeef) && 11 git commit --allow-empty -m "Initial" && 12 git tag testtag && 13 git for-each-ref >full-list && 14 git for-each-ref --format="%(objectname) %(refname)" >brief-list 15 ' 16 17 test_expect_success REFFILES 'Broken refs are reported correctly' ' 18 r=refs/heads/bogus && 19 : >.git/$r && 20 test_when_finished "rm -f .git/$r" && 21 echo "warning: ignoring broken ref $r" >broken-err && 22 git for-each-ref >out 2>err && 23 test_cmp full-list out && 24 test_cmp broken-err err 25 ' 26 27 test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' ' 28 r=refs/heads/zeros && 29 echo $ZEROS >.git/$r && 30 test_when_finished "rm -f .git/$r" && 31 echo "warning: ignoring broken ref $r" >zeros-err && 32 git for-each-ref >out 2>err && 33 test_cmp full-list out && 34 test_cmp zeros-err err && 35 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err && 36 test_cmp brief-list brief-out && 37 test_cmp zeros-err brief-err 38 ' 39 40 test_expect_success 'Missing objects are reported correctly' ' 41 test_when_finished "git update-ref -d refs/heads/missing" && 42 test-tool ref-store main update-ref msg refs/heads/missing "$MISSING" "$ZERO_OID" REF_SKIP_OID_VERIFICATION && 43 echo "fatal: missing object $MISSING for refs/heads/missing" >missing-err && 44 test_must_fail git for-each-ref 2>err && 45 test_cmp missing-err err && 46 ( 47 cat brief-list && 48 echo "$MISSING refs/heads/missing" 49 ) | sort -k 2 >missing-brief-expected && 50 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err && 51 test_cmp missing-brief-expected brief-out && 52 test_must_be_empty brief-err 53 ' 54 55 test_expect_success 'missing ancestors are reported by contains filters' ' 56 test_when_finished "git update-ref -d refs/heads/missing-parent" && 57 { 58 echo "tree $(git rev-parse HEAD^{tree})" && 59 echo "parent $MISSING" && 60 git cat-file commit HEAD | 61 sed -n -e "/^author /p" -e "/^committer /p" && 62 echo && 63 echo "missing parent" 64 } >commit && 65 broken=$(git hash-object -t commit -w commit) && 66 git update-ref refs/heads/missing-parent "$broken" && 67 for option in --contains --no-contains 68 do 69 test_must_fail git for-each-ref "$option=HEAD" \ 70 refs/heads/missing-parent >out 2>err && 71 test_must_be_empty out && 72 test_grep "parse commit $MISSING" err || 73 return 1 74 done 75 ' 76 77 test_expect_success 'ahead-behind requires an argument' ' 78 test_must_fail git for-each-ref \ 79 --format="%(ahead-behind)" 2>err && 80 echo "fatal: expected format: %(ahead-behind:)" >expect && 81 test_cmp expect err 82 ' 83 84 test_expect_success 'missing ahead-behind base' ' 85 test_must_fail git for-each-ref \ 86 --format="%(ahead-behind:refs/heads/missing)" 2>err && 87 echo "fatal: failed to find '\''refs/heads/missing'\''" >expect && 88 test_cmp expect err 89 ' 90 91 test_done