3 test_description='merge simplification'
12 git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g"
16 # Create a test repo with interesting commit graph:
18 # A--B----------G--H--I--K--L
24 # The commits are laid out from left-to-right starting with
25 # the root commit A and terminating at the tip commit L.
27 # There are a few places where we adjust the commit date or
28 # author date to make the --topo-order, --date-order, and
29 # --author-date-order flags produce different output.
31 test_expect_success setup '
32 echo "Hi there" >file &&
33 echo "initial" >lost &&
35 test_tick && git commit -m "Initial file and lost" &&
38 git branch other-branch &&
40 git symbolic-ref HEAD refs/heads/unrelated &&
42 echo "Unrelated branch" >side &&
44 test_tick && git commit -m "Side root" &&
46 git checkout master &&
49 echo "second" >lost &&
51 test_tick && GIT_AUTHOR_DATE=$(($test_tick + 120)) git commit -m "Modified file and lost" &&
54 git checkout other-branch &&
59 test_tick && git commit -m "Modified the file identically" &&
62 echo "This is a stupid example" >another-file &&
63 git add another-file &&
64 test_tick && git commit -m "Add another file" &&
68 test_must_fail git merge -m "merge" master &&
69 >lost && git commit -a -m "merge" &&
72 echo "Yet another" >elif &&
74 test_tick && git commit -m "Irrelevant change" &&
77 git checkout master &&
78 echo "Yet another" >elif &&
80 test_tick && git commit -m "Another irrelevant change" &&
83 test_tick && git merge -m "merge" other-branch &&
86 echo "Final change" >file &&
87 test_tick && git commit -a -m "Final change" &&
90 git checkout master &&
91 test_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated &&
94 echo "Immaterial" >elif &&
96 test_tick && git commit -m "Last" &&
100 FMT='tformat:%P %H | %s'
111 test_expect_$outcome "log $param" '
112 git log --pretty="$FMT" --parents $param |
114 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
115 test_cmp expect check
120 check_outcome success "$@"
123 check_result 'L K J I H F E D C G B A' --full-history --topo-order
124 check_result 'L K I H G F E D C B J A' --full-history
125 check_result 'L K I H G F E D C B J A' --full-history --date-order
126 check_result 'L K I H G F E D B C J A' --full-history --author-date-order
127 check_result 'K I H E C B A' --full-history -- file
128 check_result 'K I H E C B A' --full-history --topo-order -- file
129 check_result 'K I H E C B A' --full-history --date-order -- file
130 check_result 'K I H E B C A' --full-history --author-date-order -- file
131 check_result 'I E C B A' --simplify-merges -- file
132 check_result 'I E C B A' --simplify-merges --topo-order -- file
133 check_result 'I E C B A' --simplify-merges --date-order -- file
134 check_result 'I E B C A' --simplify-merges --author-date-order -- file
135 check_result 'I B A' -- file
136 check_result 'I B A' --topo-order -- file
137 check_result 'I B A' --date-order -- file
138 check_result 'I B A' --author-date-order -- file
139 check_result 'H' --first-parent -- another-file
140 check_result 'H' --first-parent --topo-order -- another-file
142 check_result 'E C B A' --full-history E -- lost
143 test_expect_success 'full history simplification without parent' '
144 printf "%s\n" E C B A >expect &&
145 git log --pretty="$FMT" --full-history E -- lost |
147 sed -e "s/^.* \([^ ]*\) .*/\1/" >check <actual &&
148 test_cmp expect check
151 test_expect_success '--full-diff is not affected by --parents' '
152 git log -p --pretty="%H" --full-diff -- file >expected &&
153 git log -p --pretty="%H" --full-diff --parents -- file >actual &&
154 test_cmp expected actual