| 1 | #!/bin/sh |
| 2 | |
| 3 | test_description='git pack-object --include-tag' |
| 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
| 5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 6 | |
| 7 | . ./test-lib.sh |
| 8 | |
| 9 | TRASH=$(pwd) |
| 10 | |
| 11 | test_expect_success setup ' |
| 12 | echo c >d && |
| 13 | git update-index --add d && |
| 14 | tree=$(git write-tree) && |
| 15 | commit=$(git commit-tree $tree </dev/null) && |
| 16 | echo "object $commit" >sig && |
| 17 | echo "type commit" >>sig && |
| 18 | echo "tag mytag" >>sig && |
| 19 | echo "tagger $(git var GIT_COMMITTER_IDENT)" >>sig && |
| 20 | echo >>sig && |
| 21 | echo "our test tag" >>sig && |
| 22 | tag=$(git mktag <sig) && |
| 23 | rm d sig && |
| 24 | git update-ref refs/tags/mytag $tag && { |
| 25 | echo $tree && |
| 26 | echo $commit && |
| 27 | git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/" |
| 28 | } >obj-list |
| 29 | ' |
| 30 | |
| 31 | test_expect_success 'pack without --include-tag' ' |
| 32 | packname=$(git pack-objects \ |
| 33 | --window=0 \ |
| 34 | test-no-include <obj-list) |
| 35 | ' |
| 36 | |
| 37 | test_expect_success 'unpack objects' ' |
| 38 | rm -rf clone.git && |
| 39 | git init clone.git && |
| 40 | git -C clone.git unpack-objects <test-no-include-${packname}.pack |
| 41 | ' |
| 42 | |
| 43 | test_expect_success 'check unpacked result (have commit, no tag)' ' |
| 44 | git rev-list --objects $commit >list.expect && |
| 45 | test_must_fail git -C clone.git cat-file -e $tag && |
| 46 | git -C clone.git rev-list --objects $commit >list.actual && |
| 47 | test_cmp list.expect list.actual |
| 48 | ' |
| 49 | |
| 50 | test_expect_success 'pack with --include-tag' ' |
| 51 | packname=$(git pack-objects \ |
| 52 | --window=0 \ |
| 53 | --include-tag \ |
| 54 | test-include <obj-list) |
| 55 | ' |
| 56 | |
| 57 | test_expect_success 'unpack objects' ' |
| 58 | rm -rf clone.git && |
| 59 | git init clone.git && |
| 60 | git -C clone.git unpack-objects <test-include-${packname}.pack |
| 61 | ' |
| 62 | |
| 63 | test_expect_success 'check unpacked result (have commit, have tag)' ' |
| 64 | git rev-list --objects mytag >list.expect && |
| 65 | git -C clone.git rev-list --objects $tag >list.actual && |
| 66 | test_cmp list.expect list.actual |
| 67 | ' |
| 68 | |
| 69 | # A tag of a tag, where the "inner" tag is not otherwise |
| 70 | # reachable, and a full peel points to a commit reachable from HEAD. |
| 71 | test_expect_success 'create hidden inner tag' ' |
| 72 | test_commit commit && |
| 73 | git tag -m inner inner HEAD && |
| 74 | git tag -m outer outer inner && |
| 75 | git tag -d inner |
| 76 | ' |
| 77 | |
| 78 | test_expect_success 'pack explicit outer tag' ' |
| 79 | packname=$( |
| 80 | { |
| 81 | echo HEAD && |
| 82 | echo outer |
| 83 | } | |
| 84 | git pack-objects --revs test-hidden-explicit |
| 85 | ) |
| 86 | ' |
| 87 | |
| 88 | test_expect_success 'unpack objects' ' |
| 89 | rm -rf clone.git && |
| 90 | git init clone.git && |
| 91 | git -C clone.git unpack-objects <test-hidden-explicit-${packname}.pack |
| 92 | ' |
| 93 | |
| 94 | test_expect_success 'check unpacked result (have all objects)' ' |
| 95 | git -C clone.git rev-list --objects $(git rev-parse outer HEAD) |
| 96 | ' |
| 97 | |
| 98 | test_expect_success 'pack implied outer tag' ' |
| 99 | packname=$( |
| 100 | echo HEAD | |
| 101 | git pack-objects --revs --include-tag test-hidden-implied |
| 102 | ) |
| 103 | ' |
| 104 | |
| 105 | test_expect_success 'unpack objects' ' |
| 106 | rm -rf clone.git && |
| 107 | git init clone.git && |
| 108 | git -C clone.git unpack-objects <test-hidden-implied-${packname}.pack |
| 109 | ' |
| 110 | |
| 111 | test_expect_success 'check unpacked result (have all objects)' ' |
| 112 | git -C clone.git rev-list --objects $(git rev-parse outer HEAD) |
| 113 | ' |
| 114 | |
| 115 | test_expect_success 'single-branch clone can transfer tag' ' |
| 116 | rm -rf clone.git && |
| 117 | git clone --no-local --single-branch -b main . clone.git && |
| 118 | git -C clone.git fsck |
| 119 | ' |
| 120 | |
| 121 | test_done |