Merge branch 'rs/janitorial' into maint
[git/git-svn.git] / t / t9351-fast-export-anonymize.sh
blob897dc509075a887268f472b8bbdbb5bf67e4d00f
1 #!/bin/sh
3 test_description='basic tests for fast-export --anonymize'
4 . ./test-lib.sh
6 test_expect_success 'setup simple repo' '
7 test_commit base &&
8 test_commit foo &&
9 git checkout -b other HEAD^ &&
10 mkdir subdir &&
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' '
22 ! grep base stream &&
23 ! grep foo stream &&
24 ! grep subdir stream &&
25 ! grep bar stream &&
26 ! grep xyzzy stream
29 test_expect_success 'stream allows master as refname' '
30 grep master stream
33 test_expect_success 'stream omits other refnames' '
34 ! grep other stream &&
35 ! grep mytag 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' '
52 git init new &&
53 cd new &&
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' '
64 shape () {
65 git log --format="%m %ct" --left-right --boundary "$@"
66 } &&
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 &&
77 blob
78 tree
79 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 &&
87 blob
88 blob
89 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
112 test_done