git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob 2d98318d23ed8ce9be74332274d40b4e2c291384 5152 bytes (raw)
name: t/t4209-log-pickaxe.sh 	 # note: path name is non-authoritative(*)

  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
 
#!/bin/sh

test_description='log --grep/--author/--regexp-ignore-case/-S/-G'
. ./test-lib.sh

test_log () {
	expect=$1
	kind=$2
	needle=$3
	shift 3
	rest=$@

	case $kind in
	--*)
		opt=$kind=$needle
		;;
	*)
		opt=$kind$needle
		;;
	esac
	case $expect in
	expect_nomatch)
		match=nomatch
		;;
	*)
		match=match
		;;
	esac

	test_expect_success "log $kind${rest:+ $rest} ($match)" "
		git log $rest $opt --format=%H >actual &&
		test_cmp $expect actual
	"
}

# test -i and --regexp-ignore-case and expect both to behave the same way
test_log_icase () {
	test_log $@ --regexp-ignore-case
	test_log $@ -i
}

test_expect_success setup '
	>expect_nomatch &&

	>file &&
	git add file &&
	test_tick &&
	git commit -m initial &&
	git rev-parse --verify HEAD >expect_initial &&

	echo Picked >file &&
	git add file &&
	test_tick &&
	git commit --author="Another Person <another@example.com>" -m second &&
	git rev-parse --verify HEAD >expect_second
'

test_log	expect_initial	--grep initial
test_log	expect_nomatch	--grep InItial
test_log_icase	expect_initial	--grep InItial
test_log_icase	expect_nomatch	--grep initail

test_log	expect_second	--author Person
test_log	expect_nomatch	--author person
test_log_icase	expect_second	--author person
test_log_icase	expect_nomatch	--author spreon

test_log	expect_nomatch	-G picked
test_log	expect_second	-G Picked
test_log_icase	expect_nomatch	-G pickle
test_log_icase	expect_second	-G picked

test_expect_success 'log -G --textconv (missing textconv tool)' '
	echo "* diff=test" >.gitattributes &&
	test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
	rm .gitattributes
'

test_expect_success 'log -G --no-textconv (missing textconv tool)' '
	echo "* diff=test" >.gitattributes &&
	git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
	test_cmp expect_nomatch actual &&
	rm .gitattributes
'

test_log	expect_nomatch	-S picked
test_log	expect_second	-S Picked
test_log_icase	expect_second	-S picked
test_log_icase	expect_nomatch	-S pickle

test_log	expect_nomatch	-S p.cked --pickaxe-regex
test_log	expect_second	-S P.cked --pickaxe-regex
test_log_icase	expect_second	-S p.cked --pickaxe-regex
test_log_icase	expect_nomatch	-S p.ckle --pickaxe-regex

test_expect_success 'log -S --textconv (missing textconv tool)' '
	echo "* diff=test" >.gitattributes &&
	test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
	rm .gitattributes
'

test_expect_success 'log -S --no-textconv (missing textconv tool)' '
	echo "* diff=test" >.gitattributes &&
	git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
	test_cmp expect_nomatch actual &&
	rm .gitattributes
'

test_expect_success 'setup log -[GS] binary & --text' '
	git checkout --orphan GS-binary-and-text &&
	git read-tree --empty &&
	printf "a\na\0a\n" >data.bin &&
	git add data.bin &&
	git commit -m "create binary file" data.bin &&
	printf "a\na\0a\n" >>data.bin &&
	git commit -m "modify binary file" data.bin &&
	git rm data.bin &&
	git commit -m "delete binary file" data.bin &&
	git log >full-log
'

test_expect_success 'log -G ignores binary files' '
	git log -Ga >log &&
	test_must_be_empty log
'

test_expect_success 'log -G looks into binary files with -a' '
	git log -a -Ga >log &&
	test_cmp log full-log
'

test_expect_success 'log -G looks into binary files with textconv filter' '
	test_when_finished "rm .gitattributes" &&
	echo "* diff=bin" >.gitattributes &&
	git -c diff.bin.textconv=cat log -Ga >log &&
	test_cmp log full-log
'

test_expect_success 'log -S looks into binary files' '
	git log -Sa >log &&
	test_cmp log full-log
'

test_expect_success 'setup log -G --pickaxe-raw-diff' '
	git checkout --orphan G-raw-diff &&
	test_write_lines A B C D E F G >file &&
	git add file &&
	git commit --allow-empty-message file &&
	sed -i -e "s/B/2/" file &&
	git add file &&
	git commit --allow-empty-message file &&
	sed -i -e "s/D/4/" file &&
	git add file &&
	git commit --allow-empty-message file &&
	git rm file &&
	git commit --allow-empty-message &&
	git log --oneline -1 HEAD~0 >file.fourth &&
	git log --oneline -1 HEAD~1 >file.third &&
	git log --oneline -1 HEAD~2 >file.second &&
	git log --oneline -1 HEAD~3 >file.first
'

test_expect_success 'log -G --pickaxe-raw-diff skips header and range information' '
	git log --pickaxe-raw-diff -p -G"(@@|file)" >log &&
	test_must_be_empty log
'

test_expect_success 'log -G --pickaxe-raw-diff searching in context' '
	git log --oneline --pickaxe-raw-diff -G"^ F" -U2 -s >log &&
	test_cmp file.third log &&
	git log --oneline --pickaxe-raw-diff -G"^ F" -U1 -s >log &&
	test_must_be_empty log
'

test_expect_success 'log -G --pickaxe-raw-diff searching added / removed lines (skip create/delete)' '
	git log --oneline --pickaxe-raw-diff -G"^-[D2]" -s HEAD~1 >log &&
	test_cmp file.third log &&
	git log --oneline --pickaxe-raw-diff -G"^\+[D2]" -s -1 >log &&
	test_cmp file.second log
'

test_expect_success 'log -G --pickaxe-raw-diff searching created / deleted files' '
	git log --oneline --pickaxe-raw-diff -G"^\+A" -s >log &&
	test_cmp file.first log &&
	git log --oneline --pickaxe-raw-diff -G"^\-A" -s >log &&
	test_cmp file.fourth log
'

test_done

debug log:

solving 2d98318d23 ...
found 2d98318d23 in https://public-inbox.org/git/20190424152215.16251-3-avarab@gmail.com/
found 5d06f5f45e in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 5d06f5f45eace6010c1a003e03a814b5ba03f324	t/t4209-log-pickaxe.sh

applying [1/1] https://public-inbox.org/git/20190424152215.16251-3-avarab@gmail.com/
diff --git a/t/t4209-log-pickaxe.sh b/t/t4209-log-pickaxe.sh
index 5d06f5f45e..2d98318d23 100755

Checking patch t/t4209-log-pickaxe.sh...
Applied patch t/t4209-log-pickaxe.sh cleanly.

index at:
100755 2d98318d23ed8ce9be74332274d40b4e2c291384	t/t4209-log-pickaxe.sh

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public 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).