git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
c7fd2c5f5ce4a98699fecf71c271f6e506fc0365 blob 2160 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
 
#!/bin/sh

test_description='test cloning a repository with detached HEAD'
. ./test-lib.sh

head_is_detached() {
	git --git-dir=$1/.git rev-parse --verify HEAD &&
	test_must_fail git --git-dir=$1/.git symbolic-ref HEAD
}

test_expect_success 'setup' '
	echo one >file &&
	git add file &&
	git commit -m one &&
	echo two >file &&
	git commit -a -m two &&
	git tag two &&
	git tag four $(git rev-parse :file) &&
	echo three >file &&
	git commit -a -m three
'

test_expect_success 'clone repo (detached HEAD points to branch)' '
	git checkout master^0 &&
	git clone "file://$PWD" detached-branch
'
test_expect_success 'cloned HEAD matches' '
	echo three >expect &&
	git --git-dir=detached-branch/.git log -1 --format=%s >actual &&
	test_cmp expect actual
'
test_expect_failure 'cloned HEAD is detached' '
	head_is_detached detached-branch
'

test_expect_success 'clone repo (detached HEAD points to tag)' '
	git checkout two^0 &&
	git clone "file://$PWD" detached-tag
'
test_expect_success 'cloned HEAD matches' '
	echo two >expect &&
	git --git-dir=detached-tag/.git log -1 --format=%s >actual &&
	test_cmp expect actual
'
test_expect_success 'cloned HEAD is detached' '
	head_is_detached detached-tag
'

test_expect_success 'clone repo (detached HEAD points to history)' '
	git checkout two^ &&
	git clone "file://$PWD" detached-history
'
test_expect_success 'cloned HEAD matches' '
	echo one >expect &&
	git --git-dir=detached-history/.git log -1 --format=%s >actual &&
	test_cmp expect actual
'
test_expect_success 'cloned HEAD is detached' '
	head_is_detached detached-history
'

test_expect_success 'clone repo (orphan detached HEAD)' '
	git checkout master^0 &&
	echo four >file &&
	git commit -a -m four &&
	git clone "file://$PWD" detached-orphan
'
test_expect_success 'cloned HEAD matches' '
	echo four >expect &&
	git --git-dir=detached-orphan/.git log -1 --format=%s >actual &&
	test_cmp expect actual
'
test_expect_success 'cloned HEAD is detached' '
	head_is_detached detached-orphan
'
test_expect_success 'cloning invalid tag' '
	test_must_fail git clone "file://$PWD" -b four 2>err &&
	test_i18ngrep "does not point to a commit." err
'

test_done
debug log:

solving c7fd2c5f5c ...
found c7fd2c5f5c in https://public-inbox.org/git/pull.906.git.git.1604058401991.gitgitgadget@gmail.com/
found 8b0d607df1 in git.git.git
preparing index
index prepared:
100755 8b0d607df115235365d4ffb10f6a1bddbfa842b4	t/t5610-clone-detached.sh

applying [1/1] https://public-inbox.org/git/pull.906.git.git.1604058401991.gitgitgadget@gmail.com/
diff --git a/t/t5610-clone-detached.sh b/t/t5610-clone-detached.sh
index 8b0d607df1..c7fd2c5f5c 100755

Checking patch t/t5610-clone-detached.sh...
Applied patch t/t5610-clone-detached.sh cleanly.

index at:
100755 c7fd2c5f5ce4a98699fecf71c271f6e506fc0365	t/t5610-clone-detached.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).