]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t9351-fast-export-anonymize.sh
3 test_description
='basic tests for fast-export --anonymize'
6 test_expect_success
'setup simple repo' '
9 git checkout -b other HEAD^ &&
11 test_commit subdir/bar &&
12 test_commit subdir/xyzzy &&
13 fake_commit=$(echo $ZERO_OID | sed s/0/a/) &&
14 git update-index --add --cacheinfo 160000,$fake_commit,link1 &&
15 git update-index --add --cacheinfo 160000,$fake_commit,link2 &&
16 git commit -m "add gitlink" &&
17 git tag -m "annotated tag" mytag
20 test_expect_success
'export anonymized stream' '
21 git fast-export --anonymize --all >stream
24 # this also covers commit messages
25 test_expect_success
'stream omits path names' '
28 ! grep subdir stream &&
33 test_expect_success
'stream omits gitlink oids' '
34 # avoid relying on the whole oid to remain hash-agnostic; this is
35 # plenty to be unique within our test case
36 ! grep a000000000000000000 stream
39 test_expect_success
'stream allows master as refname' '
43 test_expect_success
'stream omits other refnames' '
44 ! grep other stream &&
48 test_expect_success
'stream omits identities' '
49 ! grep "$GIT_COMMITTER_NAME" stream &&
50 ! grep "$GIT_COMMITTER_EMAIL" stream &&
51 ! grep "$GIT_AUTHOR_NAME" stream &&
52 ! grep "$GIT_AUTHOR_EMAIL" stream
55 test_expect_success
'stream omits tag message' '
56 ! grep "annotated tag" stream
59 # NOTE: we chdir to the new, anonymized repository
60 # after this. All further tests should assume this.
61 test_expect_success
'import stream to new repository' '
64 git fast-import <../stream
67 test_expect_success
'result has two branches' '
68 git for-each-ref --format="%(refname)" refs/heads >branches &&
69 test_line_count = 2 branches &&
70 other_branch=$(grep -v refs/heads/master branches)
73 test_expect_success
'repo has original shape and timestamps' '
75 git log --format="%m %ct" --left-right --boundary "$@"
77 (cd .. && shape master...other) >expect &&
78 shape master...$other_branch >actual &&
79 test_cmp expect actual
82 test_expect_success
'root tree has original shape' '
83 # the output entries are not necessarily in the same
84 # order, but we should at least have the same set of
86 git -C .. ls-tree HEAD >orig-root &&
87 cut -d" " -f2 <orig-root | sort >expect &&
88 git ls-tree $other_branch >root &&
89 cut -d" " -f2 <root | sort >actual &&
90 test_cmp expect actual
93 test_expect_success
'paths in subdir ended up in one tree' '
94 git -C .. ls-tree other:subdir >orig-subdir &&
95 cut -d" " -f2 <orig-subdir | sort >expect &&
96 tree=$(grep tree root | cut -f2) &&
97 git ls-tree $other_branch:$tree >tree &&
98 cut -d" " -f2 <tree >actual &&
99 test_cmp expect actual
102 test_expect_success
'identical gitlinks got identical oid' '
103 awk "/commit/ { print \$3 }" <root | sort -u >commits &&
104 test_line_count = 1 commits
107 test_expect_success
'tag points to branch tip' '
108 git rev-parse $other_branch >expect &&
109 git for-each-ref --format="%(*objectname)" | grep . >actual &&
110 test_cmp expect actual
113 test_expect_success
'idents are shared' '
114 git log --all --format="%an <%ae>" >authors &&
115 sort -u authors >unique &&
116 test_line_count = 1 unique &&
117 git log --all --format="%cn <%ce>" >committers &&
118 sort -u committers >unique &&
119 test_line_count = 1 unique &&
120 ! test_cmp authors committers