| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='packed-refs entries are covered by loose refs' |
| 4 | |
| 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 7 | |
| 8 | . ./test-lib.sh |
| 9 | |
| 10 | test_expect_success setup ' |
| 11 | test_tick && |
| 12 | git commit --allow-empty -m one && |
| 13 | one=$(git rev-parse HEAD) && |
| 14 | git for-each-ref >actual && |
| 15 | echo "$one commit refs/heads/main" >expect && |
| 16 | test_cmp expect actual && |
| 17 | |
| 18 | git pack-refs --all && |
| 19 | git for-each-ref >actual && |
| 20 | echo "$one commit refs/heads/main" >expect && |
| 21 | test_cmp expect actual && |
| 22 | |
| 23 | git checkout --orphan another && |
| 24 | test_tick && |
| 25 | git commit --allow-empty -m two && |
| 26 | two=$(git rev-parse HEAD) && |
| 27 | git checkout -B main && |
| 28 | git branch -D another && |
| 29 | |
| 30 | git for-each-ref >actual && |
| 31 | echo "$two commit refs/heads/main" >expect && |
| 32 | test_cmp expect actual && |
| 33 | |
| 34 | git reflog expire --expire=now --all && |
| 35 | git prune && |
| 36 | git tag -m v1.0 v1.0 main |
| 37 | ' |
| 38 | |
| 39 | test_expect_success 'no error from stale entry in packed-refs' ' |
| 40 | git describe main >actual 2>&1 && |
| 41 | echo "v1.0" >expect && |
| 42 | test_cmp expect actual |
| 43 | ' |
| 44 | |
| 45 | test_expect_success 'list packed refs with unicode characters' ' |
| 46 | test_when_finished "rm -rf repo" && |
| 47 | git init repo && |
| 48 | ( |
| 49 | cd repo && |
| 50 | test_commit --no-tag A && |
| 51 | git update-ref refs/heads/ HEAD && |
| 52 | git update-ref refs/heads/z HEAD && |
| 53 | git pack-refs --all && |
| 54 | printf "%s commit\trefs/heads/z\n" $(git rev-parse HEAD) >expect && |
| 55 | git for-each-ref refs/heads/z >actual && |
| 56 | test_cmp expect actual |
| 57 | ) |
| 58 | ' |
| 59 | |
| 60 | test_done |