git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
9c91226f73778aecc5c6cabf24e20826ae48d40c blob 5856 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
 
#!/bin/sh

test_description='merge simplification'

. ./test-lib.sh

note () {
	git tag "$1"
}

unnote () {
	git name-rev --tags --stdin | sed -e "s|$OID_REGEX (tags/\([^)]*\)) |\1 |g"
}

#
# Create a test repo with interesting commit graph:
#
# A--B----------G--H--I--K--L
#  \  \           /     /
#   \  \         /     /
#    C------E---F     J
#        \_/
#
# The commits are laid out from left-to-right starting with
# the root commit A and terminating at the tip commit L.
#
# There are a few places where we adjust the commit date or
# author date to make the --topo-order, --date-order, and
# --author-date-order flags produce different output.

test_expect_success setup '
	echo "Hi there" >file &&
	echo "initial" >lost &&
	git add file lost &&
	test_tick && git commit -m "Initial file and lost" &&
	note A &&

	git branch other-branch &&

	git symbolic-ref HEAD refs/heads/unrelated &&
	git rm -f "*" &&
	echo "Unrelated branch" >side &&
	git add side &&
	test_tick && git commit -m "Side root" &&
	note J &&
	git checkout master &&

	echo "Hello" >file &&
	echo "second" >lost &&
	git add file lost &&
	test_tick && GIT_AUTHOR_DATE=$(($test_tick + 120)) git commit -m "Modified file and lost" &&
	note B &&

	git checkout other-branch &&

	echo "Hello" >file &&
	>lost &&
	git add file lost &&
	test_tick && git commit -m "Modified the file identically" &&
	note C &&

	echo "This is a stupid example" >another-file &&
	git add another-file &&
	test_tick && git commit -m "Add another file" &&
	note D &&

	test_tick &&
	test_must_fail git merge -m "merge" master &&
	>lost && git commit -a -m "merge" &&
	note E &&

	echo "Yet another" >elif &&
	git add elif &&
	test_tick && git commit -m "Irrelevant change" &&
	note F &&

	git checkout master &&
	echo "Yet another" >elif &&
	git add elif &&
	test_tick && git commit -m "Another irrelevant change" &&
	note G &&

	test_tick && git merge -m "merge" other-branch &&
	note H &&

	echo "Final change" >file &&
	test_tick && git commit -a -m "Final change" &&
	note I &&

	git checkout master &&
	test_tick && git merge --allow-unrelated-histories -m "Coolest" unrelated &&
	note K &&

	echo "Immaterial" >elif &&
	git add elif &&
	test_tick && git commit -m "Last" &&
	note L
'

FMT='tformat:%P 	%H | %s'

check_outcome () {
	outcome=$1
	shift
	for c in $1
	do
		echo "$c"
	done >expect &&
	shift &&
	param="$*" &&
	test_expect_$outcome "log $param" '
		git log --pretty="$FMT" --parents $param |
		unnote >actual &&
		sed -e "s/^.*	\([^ ]*\) .*/\1/" >check <actual &&
		test_cmp expect check
	'
}

check_result () {
	check_outcome success "$@"
}

check_result 'L K J I H F E D C G B A' --full-history --topo-order
check_result 'L K I H G F E D C B J A' --full-history
check_result 'L K I H G F E D C B J A' --full-history --date-order
check_result 'L K I H G F E D B C J A' --full-history --author-date-order
check_result 'K I H E C B A' --full-history -- file
check_result 'K I H E C B A' --full-history --topo-order -- file
check_result 'K I H E C B A' --full-history --date-order -- file
check_result 'K I H E B C A' --full-history --author-date-order -- file
check_result 'I E C B A' --simplify-merges -- file
check_result 'I E C B A' --simplify-merges --topo-order -- file
check_result 'I E C B A' --simplify-merges --date-order -- file
check_result 'I E B C A' --simplify-merges --author-date-order -- file
check_result 'I B A' -- file
check_result 'I B A' --topo-order -- file
check_result 'I B A' --date-order -- file
check_result 'I B A' --author-date-order -- file
check_result 'H' --first-parent -- another-file
check_result 'H' --first-parent --topo-order -- another-file

check_result 'E C B A' --full-history E -- lost
test_expect_success 'full history simplification without parent' '
	printf "%s\n" E C B A >expect &&
	git log --pretty="$FMT" --full-history E -- lost |
	unnote >actual &&
	sed -e "s/^.*	\([^ ]*\) .*/\1/" >check <actual &&
	test_cmp expect check
'

test_expect_success '--full-diff is not affected by --parents' '
	git log -p --pretty="%H" --full-diff -- file >expected &&
	git log -p --pretty="%H" --full-diff --parents -- file >actual &&
	test_cmp expected actual
'

#
# Modify the test repo to add a merge whose first parent is not TREESAME
# but whose second parent is TREESAME
#
# A--B----------G--H--I--K--L--N
#  \  \           /     /     /
#   \  \         /     /     /
#    C------E---F     J     /
#     \  \_/               /
#      \                  /
#       M-----------------
test_expect_success 'expand graph' '
	git switch -c branchM C &&
	echo "new data" >file &&
	git add file &&
	test_tick &&
	test_commit M &&

	git checkout master &&
	git merge -Xtheirs branchM -m "N" &&
	note N
'

check_result 'M C A' -- file
check_result 'N M C A' --include-diversions -- file

check_result 'N M L K J I H F E D C G B A' --full-history --topo-order
check_result 'N M L K I H G F E D C B J A' --full-history
check_result 'N M L K I H G F E D C B J A' --full-history --date-order
check_result 'N M L K I H G F E D B C J A' --full-history --author-date-order
check_result 'N M K I H E C B A' --full-history -- file
check_result 'N M K I H E C B A' --full-history --topo-order -- file
check_result 'N M K I H E C B A' --full-history --date-order -- file
check_result 'N M K I H E B C A' --full-history --author-date-order -- file
check_result 'N M I E C B A' --simplify-merges -- file
check_result 'N M I E C B A' --simplify-merges --topo-order -- file
check_result 'N M I E C B A' --simplify-merges --date-order -- file
check_result 'N M I E B C A' --simplify-merges --author-date-order -- file
check_result 'M C A' --topo-order -- file
check_result 'M C A' --date-order -- file
check_result 'M C A' --author-date-order -- file
check_result 'H' --first-parent -- another-file
check_result 'H' --first-parent --topo-order -- another-file

test_done
debug log:

solving 9c91226f737 ...
found 9c91226f737 in https://public-inbox.org/git/pull.599.git.1586308923544.gitgitgadget@gmail.com/
found a10f0df02b0 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 a10f0df02b0ec8acdcaf7c90d02da4a9c20ffb1b	t/t6012-rev-list-simplify.sh

applying [1/1] https://public-inbox.org/git/pull.599.git.1586308923544.gitgitgadget@gmail.com/
diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
index a10f0df02b0..9c91226f737 100755

Checking patch t/t6012-rev-list-simplify.sh...
Applied patch t/t6012-rev-list-simplify.sh cleanly.

index at:
100755 9c91226f73778aecc5c6cabf24e20826ae48d40c	t/t6012-rev-list-simplify.sh

Code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).