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 git tag -m "annotated tag" mytag
16 test_expect_success
'export anonymized stream' '
17 git fast-export --anonymize --all >stream
20 # this also covers commit messages
21 test_expect_success
'stream omits path names' '
24 ! grep subdir stream &&
29 test_expect_success
'stream allows master as refname' '
33 test_expect_success
'stream omits other refnames' '
34 ! grep other stream &&
38 test_expect_success
'stream omits identities' '
39 ! grep "$GIT_COMMITTER_NAME" stream &&
40 ! grep "$GIT_COMMITTER_EMAIL" stream &&
41 ! grep "$GIT_AUTHOR_NAME" stream &&
42 ! grep "$GIT_AUTHOR_EMAIL" stream
45 test_expect_success
'stream omits tag message' '
46 ! grep "annotated tag" stream
49 # NOTE: we chdir to the new, anonymized repository
50 # after this. All further tests should assume this.
51 test_expect_success
'import stream to new repository' '
54 git fast-import <../stream
57 test_expect_success
'result has two branches' '
58 git for-each-ref --format="%(refname)" refs/heads >branches &&
59 test_line_count = 2 branches &&
60 other_branch=$(grep -v refs/heads/master branches)
63 test_expect_success
'repo has original shape and timestamps' '
65 git log --format="%m %ct" --left-right --boundary "$@"
67 (cd .. && shape master...other) >expect &&
68 shape master...$other_branch >actual &&
69 test_cmp expect actual
72 test_expect_success
'root tree has original shape' '
73 # the output entries are not necessarily in the same
74 # order, but we should at least have the same set of
76 git -C .. ls-tree HEAD >orig-root &&
77 cut -d" " -f2 <orig-root | sort >expect &&
78 git ls-tree $other_branch >root &&
79 cut -d" " -f2 <root | sort >actual &&
80 test_cmp expect actual
83 test_expect_success
'paths in subdir ended up in one tree' '
84 git -C .. ls-tree other:subdir >orig-subdir &&
85 cut -d" " -f2 <orig-subdir | sort >expect &&
86 tree=$(grep tree root | cut -f2) &&
87 git ls-tree $other_branch:$tree >tree &&
88 cut -d" " -f2 <tree >actual &&
89 test_cmp expect actual
92 test_expect_success
'tag points to branch tip' '
93 git rev-parse $other_branch >expect &&
94 git for-each-ref --format="%(*objectname)" | grep . >actual &&
95 test_cmp expect actual
98 test_expect_success
'idents are shared' '
99 git log --all --format="%an <%ae>" >authors &&
100 sort -u authors >unique &&
101 test_line_count = 1 unique &&
102 git log --all --format="%cn <%ce>" >committers &&
103 sort -u committers >unique &&
104 test_line_count = 1 unique &&
105 ! test_cmp authors committers