git status: Show detailed dirty status of submodules in long format
[git/git.git] / t / t7506-status-submodule.sh
CommitLineData
27bfd950
PY
1#!/bin/sh
2
47a528ad 3test_description='git status for submodule'
27bfd950
PY
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
ee6fc514
JL
8 test_create_repo sub &&
9 (
10 cd sub &&
11 : >bar &&
12 git add bar &&
13 git commit -m " Add bar" &&
14 : >foo &&
15 git add foo &&
16 git commit -m " Add foo"
17 ) &&
18 echo output > .gitignore &&
19 git add sub .gitignore &&
27bfd950
PY
20 git commit -m "Add submodule sub"
21'
22
23test_expect_success 'status clean' '
ee6fc514
JL
24 git status >output &&
25 grep "nothing to commit" output
27bfd950 26'
ee6fc514 27
9e4b7ab6 28test_expect_success 'commit --dry-run -a clean' '
ee6fc514
JL
29 test_must_fail git commit --dry-run -a >output &&
30 grep "nothing to commit" output
31'
32
33test_expect_success 'status with modified file in submodule' '
34 (cd sub && git reset --hard) &&
35 echo "changed" >sub/foo &&
36 git status >output &&
9297f77e 37 grep "modified: sub (new commits, modified content)" output
ee6fc514
JL
38'
39
40test_expect_success 'status with modified file in submodule (porcelain)' '
41 (cd sub && git reset --hard) &&
42 echo "changed" >sub/foo &&
43 git status --porcelain >output &&
44 diff output - <<-\EOF
45 M sub
46 EOF
47'
48
49test_expect_success 'status with added file in submodule' '
50 (cd sub && git reset --hard && echo >foo && git add foo) &&
51 git status >output &&
9297f77e 52 grep "modified: sub (new commits, modified content)" output
ee6fc514
JL
53'
54
55test_expect_success 'status with added file in submodule (porcelain)' '
56 (cd sub && git reset --hard && echo >foo && git add foo) &&
57 git status --porcelain >output &&
58 diff output - <<-\EOF
59 M sub
60 EOF
61'
62
63test_expect_success 'status with untracked file in submodule' '
64 (cd sub && git reset --hard) &&
65 echo "content" >sub/new-file &&
66 git status >output &&
9297f77e 67 grep "modified: sub (new commits, untracked content)" output
ee6fc514
JL
68'
69
70test_expect_success 'status with untracked file in submodule (porcelain)' '
71 git status --porcelain >output &&
72 diff output - <<-\EOF
73 M sub
74 EOF
27bfd950 75'
ee6fc514 76
27bfd950
PY
77test_expect_success 'rm submodule contents' '
78 rm -rf sub/* sub/.git
79'
ee6fc514 80
27bfd950 81test_expect_success 'status clean (empty submodule dir)' '
ee6fc514
JL
82 git status >output &&
83 grep "nothing to commit" output
27bfd950 84'
ee6fc514 85
050288d5 86test_expect_success 'status -a clean (empty submodule dir)' '
ee6fc514
JL
87 test_must_fail git commit --dry-run -a >output &&
88 grep "nothing to commit" output
27bfd950
PY
89'
90
91test_done