From 74b6fe9202792f43ba01014599c8fe183149c0a3 Mon Sep 17 00:00:00 2001 From: Luke Diamand Date: Sat, 21 Nov 2015 09:54:39 +0000 Subject: git-p4: add failing test for submit from detached head git-p4 can't submit from a detached head. This test case demonstrates the problem. Signed-off-by: Luke Diamand Signed-off-by: Jeff King --- t/t9800-git-p4-basic.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 't') diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index 90d41ed954..114b19fca8 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -241,6 +241,22 @@ test_expect_success 'unresolvable host in P4PORT should display error' ' ) ' +test_expect_failure 'submit from detached head' ' + test_when_finished cleanup_git && + git p4 clone --dest="$git" //depot && + ( + cd "$git" && + git checkout p4/master && + >detached_head_test && + git add detached_head_test && + git commit -m "add detached_head" && + git config git-p4.skipSubmitEdit true && + git p4 submit && + git p4 rebase && + git log p4/master | grep detached_head + ) +' + test_expect_success 'kill p4d' ' kill_p4d ' -- cgit v1.2.3 From 00ad6e3182bbe68a94eaedf322918e4f266d184f Mon Sep 17 00:00:00 2001 From: Luke Diamand Date: Sat, 21 Nov 2015 09:54:41 +0000 Subject: git-p4: work with a detached head When submitting, git-p4 finds the current branch in order to know if it is allowed to submit (configuration "git-p4.allowSubmit"). On a detached head, detecting the branch would fail, and git-p4 would report a cryptic error. This change teaches git-p4 to recognise a detached head and submit successfully. Signed-off-by: Luke Diamand Signed-off-by: Jeff King --- t/t9800-git-p4-basic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't') diff --git a/t/t9800-git-p4-basic.sh b/t/t9800-git-p4-basic.sh index 114b19fca8..0730f18d0f 100755 --- a/t/t9800-git-p4-basic.sh +++ b/t/t9800-git-p4-basic.sh @@ -241,7 +241,7 @@ test_expect_success 'unresolvable host in P4PORT should display error' ' ) ' -test_expect_failure 'submit from detached head' ' +test_expect_success 'submit from detached head' ' test_when_finished cleanup_git && git p4 clone --dest="$git" //depot && ( -- cgit v1.2.3