2008-05-02 15:35:34 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2008-09-03 10:59:33 +02:00
|
|
|
test_description='git status for submodule'
|
2008-05-02 15:35:34 +02:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
2010-01-16 18:42:24 +01:00
|
|
|
test_create_repo sub &&
|
|
|
|
(
|
|
|
|
cd sub &&
|
|
|
|
: >bar &&
|
|
|
|
git add bar &&
|
|
|
|
git commit -m " Add bar" &&
|
|
|
|
: >foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m " Add foo"
|
|
|
|
) &&
|
|
|
|
echo output > .gitignore &&
|
|
|
|
git add sub .gitignore &&
|
2008-05-02 15:35:34 +02:00
|
|
|
git commit -m "Add submodule sub"
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status clean' '
|
2010-01-16 18:42:24 +01:00
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'commit --dry-run -a clean' '
|
2010-01-16 18:42:24 +01:00
|
|
|
test_must_fail git commit --dry-run -a >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with modified file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with modified file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with untracked file in submodule' '
|
2010-01-16 18:42:24 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (untracked content)" output
|
2010-01-16 18:42:24 +01:00
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status -uno with untracked file in submodule' '
|
2010-03-13 23:00:27 +01:00
|
|
|
git status -uno >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "^nothing to commit" output
|
2010-03-13 23:00:27 +01:00
|
|
|
'
|
|
|
|
|
2010-01-16 18:42:24 +01:00
|
|
|
test_expect_success 'status with untracked file in submodule (porcelain)' '
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added and untracked file in submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (modified content, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added and untracked file in submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with modified file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
rm sub/new-file &&
|
|
|
|
(cd sub && echo "next change" >foo && git commit -m "next change" foo) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with modified file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "changed" >sub/foo &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with untracked file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with untracked file in modified submodule (porcelain)' '
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added and untracked file in modified submodule' '
|
2010-03-12 22:23:52 +01:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content, untracked content)" output
|
2010-03-12 22:23:52 +01:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with added and untracked file in modified submodule (porcelain)' '
|
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
echo "content" >sub/new-file &&
|
|
|
|
git status --porcelain >output &&
|
|
|
|
diff output - <<-\EOF
|
|
|
|
M sub
|
|
|
|
EOF
|
|
|
|
'
|
|
|
|
|
2010-04-10 19:01:12 +02:00
|
|
|
test_expect_success 'setup .git file for sub' '
|
|
|
|
(cd sub &&
|
|
|
|
rm -f new-file
|
|
|
|
REAL="$(pwd)/../.real" &&
|
|
|
|
mv .git "$REAL"
|
|
|
|
echo "gitdir: $REAL" >.git) &&
|
|
|
|
echo .real >>.gitignore &&
|
|
|
|
git commit -m "added .real to .gitignore" .gitignore
|
|
|
|
'
|
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status with added file in modified submodule with .git file' '
|
2010-04-10 19:01:12 +02:00
|
|
|
(cd sub && git reset --hard && echo >foo && git add foo) &&
|
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "modified: sub (new commits, modified content)" output
|
2010-04-10 19:01:12 +02:00
|
|
|
'
|
|
|
|
|
2008-05-02 15:35:34 +02:00
|
|
|
test_expect_success 'rm submodule contents' '
|
|
|
|
rm -rf sub/* sub/.git
|
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status clean (empty submodule dir)' '
|
2010-01-16 18:42:24 +01:00
|
|
|
git status >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
2010-01-16 18:42:24 +01:00
|
|
|
|
2011-04-14 22:37:54 +02:00
|
|
|
test_expect_success 'status -a clean (empty submodule dir)' '
|
2010-01-16 18:42:24 +01:00
|
|
|
test_must_fail git commit --dry-run -a >output &&
|
2011-04-14 22:37:54 +02:00
|
|
|
test_i18ngrep "nothing to commit" output
|
2008-05-02 15:35:34 +02:00
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|