git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
19f08d9ccd07a3c8d9924f43ba111149f9a4f861 blob 2793 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
 
#!/bin/sh
#
# Copyright (c) 2005 Junio C Hamano
#

test_description='git apply boundary tests

'
. ./test-lib.sh

L="c d e f g h i j k l m n o p q r s t u v w x"

test_expect_success setup '
	for i in b $L y
	do
		echo $i
	done >victim &&
	cat victim >original &&
	git update-index --add victim &&

	# add to the head
	for i in a b $L y
	do
		echo $i
	done >victim &&
	cat victim >add-a-expect &&
	git diff victim >add-a-patch.with &&
	git diff --unified=0 >add-a-patch.without &&

	# insert at line two
	for i in b a $L y
	do
		echo $i
	done >victim &&
	cat victim >insert-a-expect &&
	git diff victim >insert-a-patch.with &&
	git diff --unified=0 >insert-a-patch.without &&

	# modify at the head
	for i in a $L y
	do
		echo $i
	done >victim &&
	cat victim >mod-a-expect &&
	git diff victim >mod-a-patch.with &&
	git diff --unified=0 >mod-a-patch.without &&

	# remove from the head
	for i in $L y
	do
		echo $i
	done >victim &&
	cat victim >del-a-expect &&
	git diff victim >del-a-patch.with &&
	git diff --unified=0 >del-a-patch.without &&

	# add to the tail
	for i in b $L y z
	do
		echo $i
	done >victim &&
	cat victim >add-z-expect &&
	git diff victim >add-z-patch.with &&
	git diff --unified=0 >add-z-patch.without &&

	# modify at the tail
	for i in b $L z
	do
		echo $i
	done >victim &&
	cat victim >mod-z-expect &&
	git diff victim >mod-z-patch.with &&
	git diff --unified=0 >mod-z-patch.without &&

	# remove from the tail
	for i in b $L
	do
		echo $i
	done >victim &&
	cat victim >del-z-expect &&
	git diff victim >del-z-patch.with &&
	git diff --unified=0 >del-z-patch.without

	# done
'

for with in with without
do
	case "$with" in
	with) u= ;;
	without) u='--unidiff-zero ' ;;
	esac
	for kind in add-a add-z insert-a mod-a mod-z del-a del-z
	do
		test_expect_success "apply $kind-patch $with context" '
			cat original >victim &&
			git update-index victim &&
			git apply --index $u$kind-patch.$with &&
			test_cmp $kind-expect victim
		'
	done
done

for kind in add-a add-z insert-a mod-a mod-z del-a del-z
do
	rm -f $kind-ng.without
	sed	-e "s/^diff --git /diff /" \
		-e '/^index /d' \
		<$kind-patch.without >$kind-ng.without
	test_expect_success "apply non-git $kind-patch without context" '
		cat original >victim &&
		git update-index victim &&
		git apply --unidiff-zero --index $kind-ng.without &&
		test_cmp $kind-expect victim
	'
done

test_expect_success 'two lines' '

	>file &&
	git add file &&
	echo aaa >file &&
	git diff >patch &&
	git add file &&
	echo bbb >file &&
	git add file &&
	test_must_fail git apply --check patch

'

test_expect_success 'apply patch with 3 context lines matching at end' '
	{ echo a; echo b; echo c; echo d; } >file &&
	git add file &&
	echo e >>file &&
	git diff >patch &&
	>file &&
	test_must_fail git apply patch
'

test_done
debug log:

solving 19f08d9ccd ...
found 19f08d9ccd in https://public-inbox.org/git/20200802143018.5501-1-martin.agren@gmail.com/
found 32e3b0ee0b in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 32e3b0ee0b9d00516602934353d92da35e8b19f1	t/t4104-apply-boundary.sh

applying [1/1] https://public-inbox.org/git/20200802143018.5501-1-martin.agren@gmail.com/
diff --git a/t/t4104-apply-boundary.sh b/t/t4104-apply-boundary.sh
index 32e3b0ee0b..19f08d9ccd 100755

Checking patch t/t4104-apply-boundary.sh...
Applied patch t/t4104-apply-boundary.sh cleanly.

index at:
100755 19f08d9ccd07a3c8d9924f43ba111149f9a4f861	t/t4104-apply-boundary.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).