1#!/bin/sh
2#
3# Copyright (c) 2007 Johannes E. Schindelin
4#
5
6test_description='git-status'
7
8. ./test-lib.sh
9
10test_expect_success 'setup' '
11 : > tracked &&
12 : > modified &&
13 mkdir dir1 &&
14 : > dir1/tracked &&
15 : > dir1/modified &&
16 mkdir dir2 &&
17 : > dir1/tracked &&
18 : > dir1/modified &&
19 git add . &&
20
21 git status >output &&
22
23 test_tick &&
24 git commit -m initial &&
25 : > untracked &&
26 : > dir1/untracked &&
27 : > dir2/untracked &&
28 echo 1 > dir1/modified &&
29 echo 2 > dir2/modified &&
30 echo 3 > dir2/added &&
31 git add dir2/added
32'
33
34test_expect_success 'status (1)' '
35
36 grep -e "use \"git rm --cached <file>\.\.\.\" to unstage" output
37
38'
39
40cat > expect << \EOF
41# On branch master
42# Changes to be committed:
43# (use "git reset HEAD <file>..." to unstage)
44#
45# new file: dir2/added
46#
47# Changed but not updated:
48# (use "git add <file>..." to update what will be committed)
49#
50# modified: dir1/modified
51#
52# Untracked files:
53# (use "git add <file>..." to include in what will be committed)
54#
55# dir1/untracked
56# dir2/modified
57# dir2/untracked
58# expect
59# output
60# untracked
61EOF
62
63test_expect_success 'status (2)' '
64
65 git status > output &&
66 git diff expect output
67
68'
69
70cat > expect << \EOF
71# On branch master
72# Changes to be committed:
73# (use "git reset HEAD <file>..." to unstage)
74#
75# new file: ../dir2/added
76#
77# Changed but not updated:
78# (use "git add <file>..." to update what will be committed)
79#
80# modified: modified
81#
82# Untracked files:
83# (use "git add <file>..." to include in what will be committed)
84#
85# untracked
86# ../dir2/modified
87# ../dir2/untracked
88# ../expect
89# ../output
90# ../untracked
91EOF
92
93test_expect_success 'status with relative paths' '
94
95 (cd dir1 && git status) > output &&
96 git diff expect output
97
98'
99
100cat > expect << \EOF
101# On branch master
102# Changes to be committed:
103# (use "git reset HEAD <file>..." to unstage)
104#
105# new file: dir2/added
106#
107# Changed but not updated:
108# (use "git add <file>..." to update what will be committed)
109#
110# modified: dir1/modified
111#
112# Untracked files:
113# (use "git add <file>..." to include in what will be committed)
114#
115# dir1/untracked
116# dir2/modified
117# dir2/untracked
118# expect
119# output
120# untracked
121EOF
122
123test_expect_success 'status without relative paths' '
124
125 git config status.relativePaths false
126 (cd dir1 && git status) > output &&
127 git diff expect output
128
129'
130
131cat <<EOF >expect
132# On branch master
133# Changes to be committed:
134# (use "git reset HEAD <file>..." to unstage)
135#
136# modified: dir1/modified
137#
138# Untracked files:
139# (use "git add <file>..." to include in what will be committed)
140#
141# dir1/untracked
142# dir2/
143# expect
144# output
145# untracked
146EOF
147test_expect_success 'status of partial commit excluding new file in index' '
148 git status dir1/modified >output &&
149 diff -u expect output
150'
151
152test_done