git-p4: failing test for ignoring invalid p4 labels
When importing a label which references a commit that git-p4 does not know about, git-p4 should skip it and go on to process other labels that can be imported. Instead it crashes when attempting to find the missing commit in the git history. This test demonstrates the problem. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Luke Diamand committed
Aug 27, 2015 at 08:18 UTC
62a3c4848ec4d51e3a9f1a6be6ad0ef75a7df67e
1 file changed
+45
t/t9811-git-p4-label-import.sh
+45
@@ -214,6 +214,51 @@ test_expect_success 'use git config to enable import/export of tags' '
214
)
215
'
216
217
+p4_head_revision() {
218
+ p4 changes -m 1 "$@" | awk '{print $2}'
219
+}
220
+
221
+# Importing a label that references a P4 commit that
222
+# has not been seen. The presence of a label on a commit
223
+# we haven't seen should not cause git-p4 to fail. It should
224
+# merely skip that label, and still import other labels.
225
+test_expect_failure 'importing labels with missing revisions' '
226
+ test_when_finished cleanup_git &&
227
+ (
228
+ rm -fr "$cli" "$git" &&
229
+ mkdir "$cli" &&
230
+ P4CLIENT=missing-revision &&
231
+ client_view "//depot/missing-revision/... //missing-revision/..." &&
232
+ cd "$cli" &&
233
+ >f1 && p4 add f1 && p4 submit -d "start" &&
234
+
235
+ p4 tag -l TAG_S0 ... &&
236
+
237
+ >f2 && p4 add f2 && p4 submit -d "second" &&
238
+
239
+ startrev=$(p4_head_revision //depot/missing-revision/...) &&
240
+
241
+ >f3 && p4 add f3 && p4 submit -d "third" &&
242
+
243
+ p4 edit f2 && date >f2 && p4 submit -d "change" f2 &&
244
+
245
+ endrev=$(p4_head_revision //depot/missing-revision/...) &&
246
+
247
+ p4 tag -l TAG_S1 ... &&
248
+
249
+ # we should skip TAG_S0 since it is before our startpoint,
250
+ # but pick up TAG_S1.
251
+
252
+ git p4 clone --dest="$git" --import-labels -v \
253
+ //depot/missing-revision/...@$startrev,$endrev &&
254
+ (
255
+ cd "$git" &&
256
+ git rev-parse TAG_S1 &&
257
+ ! git rev-parse TAG_S0
258
+ )
259
+ )
260
+'
261
+
262
263
test_expect_success 'kill p4d' '
264
kill_p4d