2007-11-11 17:35:41 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
2008-09-03 08:59:33 +00:00
|
|
|
test_description='git status'
|
2007-11-11 17:35:41 +00:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
|
|
|
test_expect_success 'setup' '
|
|
|
|
: > tracked &&
|
|
|
|
: > modified &&
|
|
|
|
mkdir dir1 &&
|
|
|
|
: > dir1/tracked &&
|
|
|
|
: > dir1/modified &&
|
|
|
|
mkdir dir2 &&
|
|
|
|
: > dir1/tracked &&
|
|
|
|
: > dir1/modified &&
|
|
|
|
git add . &&
|
2008-02-12 05:45:18 +00:00
|
|
|
|
|
|
|
git status >output &&
|
|
|
|
|
2007-11-11 17:35:41 +00:00
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
|
|
|
: > untracked &&
|
|
|
|
: > dir1/untracked &&
|
|
|
|
: > dir2/untracked &&
|
|
|
|
echo 1 > dir1/modified &&
|
|
|
|
echo 2 > dir2/modified &&
|
|
|
|
echo 3 > dir2/added &&
|
|
|
|
git add dir2/added
|
|
|
|
'
|
|
|
|
|
2008-02-12 05:45:18 +00:00
|
|
|
test_expect_success 'status (1)' '
|
|
|
|
|
2008-03-12 21:32:17 +00:00
|
|
|
grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
2008-02-12 05:45:18 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-11-11 17:35:41 +00:00
|
|
|
cat > expect << \EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2007-11-11 17:35:41 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
|
2008-02-12 05:45:18 +00:00
|
|
|
test_expect_success 'status (2)' '
|
2007-11-11 17:35:41 +00:00
|
|
|
|
|
|
|
git status > output &&
|
2008-05-24 05:28:56 +00:00
|
|
|
test_cmp expect output
|
2007-11-11 17:35:41 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-06-05 12:22:56 +00:00
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-06-05 12:22:56 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files not listed (use -u option to show untracked files)
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -uno' '
|
|
|
|
mkdir dir3 &&
|
|
|
|
: > dir3/untracked1 &&
|
|
|
|
: > dir3/untracked2 &&
|
|
|
|
git status -uno >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-06-05 12:47:50 +00:00
|
|
|
test_expect_success 'status (status.showUntrackedFiles no)' '
|
|
|
|
git config status.showuntrackedfiles no
|
|
|
|
git status >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-06-05 08:31:19 +00:00
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-06-05 08:31:19 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# dir3/
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -unormal' '
|
|
|
|
git status -unormal >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-06-05 12:47:50 +00:00
|
|
|
test_expect_success 'status (status.showUntrackedFiles normal)' '
|
|
|
|
git config status.showuntrackedfiles normal
|
|
|
|
git status >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-06-05 08:31:19 +00:00
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-06-05 08:31:19 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# dir3/untracked1
|
|
|
|
# dir3/untracked2
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -uall' '
|
|
|
|
git status -uall >output &&
|
2008-06-05 12:47:50 +00:00
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
test_expect_success 'status (status.showUntrackedFiles all)' '
|
|
|
|
git config status.showuntrackedfiles all
|
|
|
|
git status >output &&
|
2008-06-05 08:31:19 +00:00
|
|
|
rm -rf dir3 &&
|
2008-06-05 12:47:50 +00:00
|
|
|
git config --unset status.showuntrackedfiles &&
|
2008-06-05 08:31:19 +00:00
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2007-11-11 17:35:41 +00:00
|
|
|
cat > expect << \EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: ../dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2007-11-11 17:35:41 +00:00
|
|
|
#
|
2007-12-03 05:30:01 +00:00
|
|
|
# modified: modified
|
2007-11-11 17:35:41 +00:00
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# untracked
|
|
|
|
# ../dir2/modified
|
|
|
|
# ../dir2/untracked
|
|
|
|
# ../expect
|
|
|
|
# ../output
|
|
|
|
# ../untracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status with relative paths' '
|
|
|
|
|
|
|
|
(cd dir1 && git status) > output &&
|
2008-05-24 05:28:56 +00:00
|
|
|
test_cmp expect output
|
2007-11-11 17:35:41 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-07 21:26:07 +00:00
|
|
|
cat > expect << \EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2007-12-07 21:26:07 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status without relative paths' '
|
|
|
|
|
|
|
|
git config status.relativePaths false
|
|
|
|
(cd dir1 && git status) > output &&
|
2008-05-24 05:28:56 +00:00
|
|
|
test_cmp expect output
|
2007-12-07 21:26:07 +00:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2008-02-14 17:18:23 +00:00
|
|
|
cat <<EOF >expect
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status of partial commit excluding new file in index' '
|
|
|
|
git status dir1/modified >output &&
|
2008-03-12 21:36:36 +00:00
|
|
|
test_cmp expect output
|
2008-02-14 17:18:23 +00:00
|
|
|
'
|
|
|
|
|
2008-04-12 15:05:33 +00:00
|
|
|
test_expect_success 'setup status submodule summary' '
|
|
|
|
test_create_repo sm && (
|
|
|
|
cd sm &&
|
|
|
|
>foo &&
|
|
|
|
git add foo &&
|
|
|
|
git commit -m "Add foo"
|
|
|
|
) &&
|
|
|
|
git add sm
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
# new file: sm
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-04-12 15:05:33 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status submodule summary is disabled by default' '
|
|
|
|
git status >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-10-16 15:07:26 +00:00
|
|
|
# we expect the same as the previous test
|
|
|
|
test_expect_success 'status --untracked-files=all does not show submodule' '
|
|
|
|
git status --untracked-files=all >output &&
|
2008-04-12 15:05:33 +00:00
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
head=$(cd sm && git rev-parse --short=7 --verify HEAD)
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
# new file: sm
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-04-12 15:05:33 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Modified submodules:
|
|
|
|
#
|
|
|
|
# * sm 0000000...$head (1):
|
|
|
|
# > Add foo
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status submodule summary' '
|
|
|
|
git config status.submodulesummary 10 &&
|
|
|
|
git status >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-04-12 15:05:33 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
no changes added to commit (use "git add" and/or "git commit -a")
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status submodule summary (clean submodule)' '
|
|
|
|
git commit -m "commit submodule" &&
|
|
|
|
git config status.submodulesummary 10 &&
|
|
|
|
test_must_fail git status >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<EOF
|
|
|
|
# On branch master
|
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD^1 <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
# new file: sm
|
|
|
|
#
|
|
|
|
# Changed but not updated:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-07 22:05:03 +00:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2008-04-12 15:05:33 +00:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Modified submodules:
|
|
|
|
#
|
|
|
|
# * sm 0000000...$head (1):
|
|
|
|
# > Add foo
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# expect
|
|
|
|
# output
|
|
|
|
# untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status submodule summary (--amend)' '
|
|
|
|
git config status.submodulesummary 10 &&
|
|
|
|
git status --amend >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2007-11-11 17:35:41 +00:00
|
|
|
test_done
|