mirror of
https://github.com/git/git.git
synced 2024-11-05 08:47:56 +01:00
aadbe44f88
System V versions of grep (such as Solaris /usr/bin/grep) don't understand either of these options. git's usage of "grep -e pattern" fell into one of two categories: 1. equivalent to "grep pattern". -e is only useful here if the pattern begins with a "-", but all of the patterns are hardcoded and do not begin with a dash. 2. stripping comments and blank lines with grep -v -e "^$" -e "^#" We can fortunately do this in the affirmative as grep '^[^#]' Uses of "-q" can be replaced with redirection to /dev/null. In many tests, however, "grep -q" is used as "if this string is in the expected output, we are OK". In this case, it is fine to just remove the "-q" entirely; it simply makes the "verbose" mode of the test slightly more verbose. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
152 lines
2.7 KiB
Bash
Executable file
152 lines
2.7 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
#
|
|
|
|
test_description='git-status'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success 'setup' '
|
|
: > tracked &&
|
|
: > modified &&
|
|
mkdir dir1 &&
|
|
: > dir1/tracked &&
|
|
: > dir1/modified &&
|
|
mkdir dir2 &&
|
|
: > dir1/tracked &&
|
|
: > dir1/modified &&
|
|
git add . &&
|
|
|
|
git status >output &&
|
|
|
|
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
|
|
'
|
|
|
|
test_expect_success 'status (1)' '
|
|
|
|
grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
|
|
|
'
|
|
|
|
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)
|
|
#
|
|
# 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 (2)' '
|
|
|
|
git status > output &&
|
|
git diff expect output
|
|
|
|
'
|
|
|
|
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)
|
|
#
|
|
# modified: modified
|
|
#
|
|
# 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 &&
|
|
git diff expect output
|
|
|
|
'
|
|
|
|
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)
|
|
#
|
|
# 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 &&
|
|
git diff expect output
|
|
|
|
'
|
|
|
|
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 &&
|
|
diff -u expect output
|
|
'
|
|
|
|
test_done
|