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/t9351-fast-export-anonymize.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 / t9351-fast-export-anonymize.sh` 141 lines ยท 4061 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='basic tests for fast-export --anonymize' 4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 6 7 . ./test-lib.sh 8 9 test_expect_success 'setup simple repo' ' 10 test_commit base && 11 test_commit foo && 12 test_commit retain-me && 13 git checkout -b other HEAD^ && 14 mkdir subdir && 15 test_commit subdir/bar && 16 test_commit subdir/xyzzy && 17 fake_commit=$(echo $ZERO_OID | sed s/0/a/) && 18 git update-index --add --cacheinfo 160000,$fake_commit,link1 && 19 git update-index --add --cacheinfo 160000,$fake_commit,link2 && 20 git commit -m "add gitlink" && 21 git tag -m "annotated tag" mytag && 22 git tag -m "annotated tag with long message" longtag 23 ' 24 25 test_expect_success 'export anonymized stream' ' 26 git fast-export --anonymize --all \ 27 --anonymize-map=retain-me \ 28 --anonymize-map=xyzzy:should-not-appear \ 29 --anonymize-map=xyzzy:custom-name \ 30 --anonymize-map=other \ 31 >stream 32 ' 33 34 # this also covers commit messages 35 test_expect_success 'stream omits path names' ' 36 test_grep ! base stream && 37 test_grep ! foo stream && 38 test_grep ! subdir stream && 39 test_grep ! bar stream && 40 test_grep ! xyzzy stream 41 ' 42 43 test_expect_success 'stream contains user-specified names' ' 44 test_grep retain-me stream && 45 test_grep ! should-not-appear stream && 46 test_grep custom-name stream 47 ' 48 49 test_expect_success 'stream omits gitlink oids' ' 50 # avoid relying on the whole oid to remain hash-agnostic; this is 51 # plenty to be unique within our test case 52 test_grep ! `a000000000000000000` stream 53 ' 54 55 test_expect_success 'stream retains other as refname' ' 56 test_grep other stream 57 ' 58 59 test_expect_success 'stream omits other refnames' ' 60 test_grep ! main stream && 61 test_grep ! mytag stream && 62 test_grep ! longtag stream 63 ' 64 65 test_expect_success 'stream omits identities' ' 66 test_grep ! "$GIT_COMMITTER_NAME" stream && 67 test_grep ! "$GIT_COMMITTER_EMAIL" stream && 68 test_grep ! "$GIT_AUTHOR_NAME" stream && 69 test_grep ! "$GIT_AUTHOR_EMAIL" stream 70 ' 71 72 test_expect_success 'stream omits tag message' ' 73 test_grep ! "annotated tag" stream 74 ' 75 76 # NOTE: we chdir to the new, anonymized repository 77 # after this. All further tests should assume this. 78 test_expect_success 'import stream to new repository' ' 79 git init new && 80 cd new && 81 git fast-import <../stream 82 ' 83 84 test_expect_success 'result has two branches' ' 85 git for-each-ref --format="%(refname)" refs/heads >branches && 86 test_line_count = 2 branches && 87 other_branch=refs/heads/other && 88 main_branch=$(grep -v $other_branch branches) 89 ' 90 91 test_expect_success 'repo has original shape and timestamps' ' 92 shape () { 93 git log --format="%m %ct" --left-right --boundary "$@" 94 } && 95 (cd .. && shape main...other) >expect && 96 shape $main_branch...$other_branch >actual && 97 test_cmp expect actual 98 ' 99 100 test_expect_success 'root tree has original shape' ' 101 # the output entries are not necessarily in the same 102 # order, but we should at least have the same set of 103 # object types. 104 git -C .. ls-tree HEAD >orig-root && 105 cut -d" " -f2 expect && 106 git ls-tree $other_branch >root && 107 cut -d" " -f2 actual && 108 test_cmp expect actual 109 ' 110 111 test_expect_success 'paths in subdir ended up in one tree' ' 112 git -C .. ls-tree other:subdir >orig-subdir && 113 cut -d" " -f2 expect && 114 tree=$(grep tree root | cut -f2) && 115 git ls-tree $other_branch:$tree >tree && 116 cut -d" " -f2 actual && 117 test_cmp expect actual 118 ' 119 120 test_expect_success 'identical gitlinks got identical oid' ' 121 awk "/commit/ { print \$3 }" commits && 122 test_line_count = 1 commits 123 ' 124 125 test_expect_success 'all tags point to branch tip' ' 126 git rev-parse $other_branch >expect && 127 git for-each-ref --format="%(*objectname)" | grep . | uniq >actual && 128 test_cmp expect actual 129 ' 130 131 test_expect_success 'idents are shared' ' 132 git log --all --format="%an <%ae>" >authors && 133 sort -u authors >unique && 134 test_line_count = 1 unique && 135 git log --all --format="%cn <%ce>" >committers && 136 sort -u committers >unique && 137 test_line_count = 1 unique && 138 ! test_cmp authors committers 139 ' 140 141 test_done