blob: 6d0957981e96211f9a4236b5649985c39b680f21 (
plain)
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
|
#!/bin/sh
test_description='require_clean_work_tree'
. ./test-lib.sh
run_require_clean_work_tree () {
(
. "$(git --exec-path)"/git-sh-setup &&
require_clean_work_tree "do-something"
)
}
test_expect_success 'setup' '
test_commit initial file
'
test_expect_success 'success on clean index and worktree' '
run_require_clean_work_tree
'
test_expect_success 'error on dirty worktree' '
test_when_finished "git reset --hard" &&
echo dirty >file &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'error on dirty index' '
test_when_finished "git reset --hard" &&
echo dirty >file &&
git add file &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'error on dirty index and worktree' '
test_when_finished "git reset --hard" &&
echo dirty >file &&
git add file &&
echo dirtier >file &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'error on clean index and worktree while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
git reset --hard &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'error on dirty index while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'error on dirty index and work tree while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
echo dirty >file &&
test_must_fail run_require_clean_work_tree
'
test_expect_success 'ORPHAN_OK - success on clean index and worktree while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
git reset --hard &&
(
ORPHAN_OK=Yes &&
run_require_clean_work_tree
)
'
test_expect_success 'ORPHAN_OK - error on dirty index while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
(
ORPHAN_OK=Yes &&
test_must_fail run_require_clean_work_tree
)
'
test_expect_success 'ORPHAN_OK - error on dirty index and worktree while on orphan branch' '
test_when_finished "git checkout master" &&
git checkout --orphan orphan &&
echo dirty >file &&
(
ORPHAN_OK=Yes &&
test_must_fail run_require_clean_work_tree
)
'
test_done
|