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 know at least that we will have one tree
75 # and one blob, so just check the sorted order
76 cat >expect <<-\EOF &&
80 git ls-tree $other_branch >root &&
81 cut -d" " -f2 <root | sort >actual &&
82 test_cmp expect actual
85 test_expect_success
'paths in subdir ended up in one tree' '
86 cat >expect <<-\EOF &&
90 tree=$(grep tree root | cut -f2) &&
91 git ls-tree $other_branch:$tree >tree &&
92 cut -d" " -f2 <tree >actual &&
93 test_cmp expect actual
96 test_expect_success
'tag points to branch tip' '
97 git rev-parse $other_branch >expect &&
98 git for-each-ref --format="%(*objectname)" | grep . >actual &&
99 test_cmp expect actual
102 test_expect_success
'idents are shared' '
103 git log --all --format="%an <%ae>" >authors &&
104 sort -u authors >unique &&
105 test_line_count = 1 unique &&
106 git log --all --format="%cn <%ce>" >committers &&
107 sort -u committers >unique &&
108 test_line_count = 1 unique &&
109 ! test_cmp authors committers