Skip to content

Commit 62a3c48

Browse files
luked99gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3a9835b commit 62a3c48

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

t/t9811-git-p4-label-import.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,51 @@ test_expect_success 'use git config to enable import/export of tags' '
214214
)
215215
'
216216

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+
217262

218263
test_expect_success 'kill p4d' '
219264
kill_p4d

0 commit comments

Comments
 (0)