2007-11-11 20:35:41 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2007 Johannes E. Schindelin
|
|
|
|
#
|
|
|
|
|
2008-09-03 12:59:33 +04:00
|
|
|
test_description='git status'
|
2007-11-11 20:35:41 +03:00
|
|
|
|
|
|
|
. ./test-lib.sh
|
2017-10-03 16:43:29 +03:00
|
|
|
. "$TEST_DIRECTORY"/lib-terminal.sh
|
2007-11-11 20:35:41 +03:00
|
|
|
|
2010-10-22 10:45:47 +04:00
|
|
|
test_expect_success 'status -h in broken repository' '
|
2013-03-13 16:59:16 +04:00
|
|
|
git config --global advice.statusuoption false &&
|
2010-10-22 10:45:47 +04:00
|
|
|
mkdir broken &&
|
|
|
|
test_when_finished "rm -fr broken" &&
|
|
|
|
(
|
|
|
|
cd broken &&
|
|
|
|
git init &&
|
|
|
|
echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
|
|
|
|
test_expect_code 129 git status -h >usage 2>&1
|
|
|
|
) &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ngrep "[Uu]sage" broken/usage
|
2010-10-22 10:45:47 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit -h in broken repository' '
|
|
|
|
mkdir broken &&
|
|
|
|
test_when_finished "rm -fr broken" &&
|
|
|
|
(
|
|
|
|
cd broken &&
|
|
|
|
git init &&
|
|
|
|
echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
|
|
|
|
test_expect_code 129 git commit -h >usage 2>&1
|
|
|
|
) &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ngrep "[Uu]sage" broken/usage
|
2010-10-22 10:45:47 +04:00
|
|
|
'
|
|
|
|
|
2017-04-27 12:01:05 +03:00
|
|
|
test_expect_success 'create upstream branch' '
|
|
|
|
git checkout -b upstream &&
|
|
|
|
test_commit upstream1 &&
|
|
|
|
test_commit upstream2 &&
|
|
|
|
# leave the first commit on master as root because several
|
|
|
|
# tests depend on this case; for our upstream we only
|
|
|
|
# care about commit counts anyway, so a totally divergent
|
|
|
|
# history is OK
|
|
|
|
git checkout --orphan master
|
|
|
|
'
|
|
|
|
|
2007-11-11 20:35:41 +03:00
|
|
|
test_expect_success 'setup' '
|
2009-12-08 13:12:02 +03:00
|
|
|
: >tracked &&
|
|
|
|
: >modified &&
|
2007-11-11 20:35:41 +03:00
|
|
|
mkdir dir1 &&
|
2009-12-08 13:12:02 +03:00
|
|
|
: >dir1/tracked &&
|
|
|
|
: >dir1/modified &&
|
2007-11-11 20:35:41 +03:00
|
|
|
mkdir dir2 &&
|
2009-12-08 13:12:02 +03:00
|
|
|
: >dir1/tracked &&
|
|
|
|
: >dir1/modified &&
|
2007-11-11 20:35:41 +03:00
|
|
|
git add . &&
|
2008-02-12 08:45:18 +03:00
|
|
|
|
|
|
|
git status >output &&
|
|
|
|
|
2007-11-11 20:35:41 +03:00
|
|
|
test_tick &&
|
|
|
|
git commit -m initial &&
|
2009-12-08 13:12:02 +03:00
|
|
|
: >untracked &&
|
|
|
|
: >dir1/untracked &&
|
|
|
|
: >dir2/untracked &&
|
|
|
|
echo 1 >dir1/modified &&
|
|
|
|
echo 2 >dir2/modified &&
|
|
|
|
echo 3 >dir2/added &&
|
2017-04-27 12:01:05 +03:00
|
|
|
git add dir2/added &&
|
|
|
|
|
|
|
|
git branch --set-upstream-to=upstream
|
2007-11-11 20:35:41 +03:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status (1)' '
|
|
|
|
test_i18ngrep "use \"git rm --cached <file>\.\.\.\" to unstage" output
|
2008-02-12 08:45:18 +03:00
|
|
|
'
|
|
|
|
|
2013-09-06 21:43:07 +04:00
|
|
|
strip_comments () {
|
2013-09-14 08:47:12 +04:00
|
|
|
tab=' '
|
|
|
|
sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
|
2013-09-06 21:43:07 +04:00
|
|
|
rm "$1" && mv "$1".tmp "$1"
|
|
|
|
}
|
|
|
|
|
2015-03-06 12:43:33 +03:00
|
|
|
cat >.gitignore <<\EOF
|
|
|
|
.gitignore
|
|
|
|
expect*
|
|
|
|
output*
|
|
|
|
EOF
|
|
|
|
|
2012-04-13 14:54:39 +04:00
|
|
|
test_expect_success 'status --column' '
|
|
|
|
cat >expect <<\EOF &&
|
|
|
|
# On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
# Your branch and '\''upstream'\'' have diverged,
|
|
|
|
# and have 1 and 2 different commits each, respectively.
|
|
|
|
# (use "git pull" to merge the remote branch into yours)
|
|
|
|
#
|
2012-04-13 14:54:39 +04:00
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
|
|
|
# Changes not staged for commit:
|
|
|
|
# (use "git add <file>..." to update what will be committed)
|
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
2015-03-06 12:43:33 +03:00
|
|
|
# dir1/untracked dir2/untracked
|
|
|
|
# dir2/modified untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
#
|
2012-04-13 14:54:39 +04:00
|
|
|
EOF
|
2013-09-06 21:43:07 +04:00
|
|
|
COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
|
|
|
|
test_i18ncmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status --column status.displayCommentPrefix=false' '
|
|
|
|
strip_comments expect &&
|
|
|
|
COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output &&
|
2012-08-27 09:36:51 +04:00
|
|
|
test_i18ncmp expect output
|
2012-04-13 14:54:39 +04:00
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
2007-11-11 20:35:41 +03:00
|
|
|
# On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
# Your branch and 'upstream' have diverged,
|
|
|
|
# and have 1 and 2 different commits each, respectively.
|
|
|
|
# (use "git pull" to merge the remote branch into yours)
|
|
|
|
#
|
2007-11-11 20:35:41 +03:00
|
|
|
# Changes to be committed:
|
|
|
|
# (use "git reset HEAD <file>..." to unstage)
|
|
|
|
#
|
|
|
|
# new file: dir2/added
|
|
|
|
#
|
2010-11-02 18:31:19 +03:00
|
|
|
# Changes not staged for commit:
|
2007-11-11 20:35:41 +03:00
|
|
|
# (use "git add <file>..." to update what will be committed)
|
2008-09-08 02:05:03 +04:00
|
|
|
# (use "git checkout -- <file>..." to discard changes in working directory)
|
2007-11-11 20:35:41 +03:00
|
|
|
#
|
|
|
|
# modified: dir1/modified
|
|
|
|
#
|
|
|
|
# Untracked files:
|
|
|
|
# (use "git add <file>..." to include in what will be committed)
|
|
|
|
#
|
|
|
|
# dir1/untracked
|
|
|
|
# dir2/modified
|
|
|
|
# dir2/untracked
|
|
|
|
# untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
#
|
2007-11-11 20:35:41 +03:00
|
|
|
EOF
|
|
|
|
|
2013-09-06 21:43:07 +04:00
|
|
|
test_expect_success 'status with status.displayCommentPrefix=true' '
|
|
|
|
git -c status.displayCommentPrefix=true status >output &&
|
|
|
|
test_i18ncmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with status.displayCommentPrefix=false' '
|
|
|
|
strip_comments expect &&
|
|
|
|
git -c status.displayCommentPrefix=false status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2007-11-11 20:35:41 +03:00
|
|
|
'
|
|
|
|
|
2015-03-06 12:43:34 +03:00
|
|
|
test_expect_success 'status -v' '
|
|
|
|
(cat expect && git diff --cached) >expect-with-v &&
|
|
|
|
git status -v >output &&
|
|
|
|
test_i18ncmp expect-with-v output
|
|
|
|
'
|
|
|
|
|
2015-03-06 12:43:35 +03:00
|
|
|
test_expect_success 'status -v -v' '
|
|
|
|
(cat expect &&
|
|
|
|
echo "Changes to be committed:" &&
|
|
|
|
git -c diff.mnemonicprefix=true diff --cached &&
|
|
|
|
echo "--------------------------------------------------" &&
|
|
|
|
echo "Changes not staged for commit:" &&
|
|
|
|
git -c diff.mnemonicprefix=true diff) >expect-with-v &&
|
|
|
|
git status -v -v >output &&
|
|
|
|
test_i18ncmp expect-with-v output
|
|
|
|
'
|
|
|
|
|
2013-09-06 21:43:07 +04:00
|
|
|
test_expect_success 'setup fake editor' '
|
|
|
|
cat >.git/editor <<-\EOF &&
|
|
|
|
#! /bin/sh
|
|
|
|
cp "$1" output
|
|
|
|
EOF
|
|
|
|
chmod 755 .git/editor
|
|
|
|
'
|
|
|
|
|
|
|
|
commit_template_commented () {
|
|
|
|
(
|
|
|
|
EDITOR=.git/editor &&
|
|
|
|
export EDITOR &&
|
|
|
|
# Fails due to empty message
|
|
|
|
test_must_fail git commit
|
|
|
|
) &&
|
|
|
|
! grep '^[^#]' output
|
|
|
|
}
|
|
|
|
|
|
|
|
test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_EDITMSG' '
|
|
|
|
commit_template_commented
|
|
|
|
'
|
|
|
|
|
2010-04-23 00:30:19 +04:00
|
|
|
cat >expect <<\EOF
|
2013-09-06 21:43:08 +04:00
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and 'upstream' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2010-04-23 00:30:19 +04:00
|
|
|
EOF
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status (advice.statusHints false)' '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config advice.statusHints false &&
|
2010-04-23 00:30:19 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-04-23 00:30:19 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
2009-11-28 00:29:30 +03:00
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
|
2010-05-25 18:52:03 +04:00
|
|
|
test_expect_success 'status -s' '
|
2009-11-28 00:29:30 +03:00
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
git status -s >output &&
|
2009-11-28 00:29:30 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2011-06-02 20:07:11 +04:00
|
|
|
test_expect_success 'status with gitignore' '
|
|
|
|
{
|
|
|
|
echo ".gitignore" &&
|
2015-03-06 12:43:34 +03:00
|
|
|
echo "expect*" &&
|
2011-06-02 20:07:11 +04:00
|
|
|
echo "output" &&
|
|
|
|
echo "untracked"
|
|
|
|
} >.gitignore &&
|
|
|
|
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir2/modified
|
|
|
|
EOF
|
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output &&
|
|
|
|
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir2/modified
|
|
|
|
!! .gitignore
|
|
|
|
!! dir1/untracked
|
|
|
|
!! dir2/untracked
|
|
|
|
!! expect
|
2015-03-06 12:43:34 +03:00
|
|
|
!! expect-with-v
|
2011-06-02 20:07:11 +04:00
|
|
|
!! output
|
|
|
|
!! untracked
|
|
|
|
EOF
|
|
|
|
git status -s --ignored >output &&
|
|
|
|
test_cmp expect output &&
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<\EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
dir2/modified
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Ignored files:
|
|
|
|
(use "git add -f <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitignore
|
|
|
|
dir1/untracked
|
|
|
|
dir2/untracked
|
|
|
|
expect
|
2015-03-06 12:43:34 +03:00
|
|
|
expect-with-v
|
2013-09-06 21:43:08 +04:00
|
|
|
output
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2011-06-02 20:07:11 +04:00
|
|
|
git status --ignored >output &&
|
2011-11-05 21:28:43 +04:00
|
|
|
test_i18ncmp expect output
|
2011-06-02 20:07:11 +04:00
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status with gitignore (nothing untracked)' '
|
|
|
|
{
|
|
|
|
echo ".gitignore" &&
|
2015-03-06 12:43:34 +03:00
|
|
|
echo "expect*" &&
|
2011-06-02 20:07:11 +04:00
|
|
|
echo "dir2/modified" &&
|
|
|
|
echo "output" &&
|
|
|
|
echo "untracked"
|
|
|
|
} >.gitignore &&
|
|
|
|
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
EOF
|
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output &&
|
|
|
|
|
|
|
|
cat >expect <<-\EOF &&
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
!! .gitignore
|
|
|
|
!! dir1/untracked
|
|
|
|
!! dir2/modified
|
|
|
|
!! dir2/untracked
|
|
|
|
!! expect
|
2015-03-06 12:43:34 +03:00
|
|
|
!! expect-with-v
|
2011-06-02 20:07:11 +04:00
|
|
|
!! output
|
|
|
|
!! untracked
|
|
|
|
EOF
|
|
|
|
git status -s --ignored >output &&
|
|
|
|
test_cmp expect output &&
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<\EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Ignored files:
|
|
|
|
(use "git add -f <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitignore
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
expect
|
2015-03-06 12:43:34 +03:00
|
|
|
expect-with-v
|
2013-09-06 21:43:08 +04:00
|
|
|
output
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2011-06-02 20:07:11 +04:00
|
|
|
git status --ignored >output &&
|
2011-11-05 21:28:43 +04:00
|
|
|
test_i18ncmp expect output
|
2011-06-02 20:07:11 +04:00
|
|
|
'
|
|
|
|
|
2015-03-06 12:43:33 +03:00
|
|
|
cat >.gitignore <<\EOF
|
|
|
|
.gitignore
|
|
|
|
expect*
|
|
|
|
output*
|
|
|
|
EOF
|
2011-06-02 20:07:11 +04:00
|
|
|
|
2010-05-25 18:52:03 +04:00
|
|
|
cat >expect <<\EOF
|
2017-04-27 12:01:05 +03:00
|
|
|
## master...upstream [ahead 1, behind 2]
|
2010-05-25 18:52:03 +04:00
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status -s -b' '
|
|
|
|
|
|
|
|
git status -s -b >output &&
|
2017-05-05 21:19:32 +03:00
|
|
|
test_i18ncmp expect output
|
2010-05-25 18:52:03 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2012-05-08 01:02:18 +04:00
|
|
|
test_expect_success 'status -s -z -b' '
|
|
|
|
tr "\\n" Q <expect >expect.q &&
|
|
|
|
mv expect.q expect &&
|
|
|
|
git status -s -z -b >output &&
|
|
|
|
nul_to_q <output >output.q &&
|
|
|
|
mv output.q output &&
|
2017-05-05 21:19:32 +03:00
|
|
|
test_i18ncmp expect output
|
2012-05-08 01:02:18 +04:00
|
|
|
'
|
|
|
|
|
2011-02-23 02:42:13 +03:00
|
|
|
test_expect_success 'setup dir3' '
|
|
|
|
mkdir dir3 &&
|
|
|
|
: >dir3/untracked1 &&
|
|
|
|
: >dir3/untracked2
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status -uno' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files not listed (use -u option to show untracked files)
|
|
|
|
EOF
|
2008-06-05 16:22:56 +04:00
|
|
|
git status -uno >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 16:22:56 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status (status.showUntrackedFiles no)' '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config status.showuntrackedfiles no &&
|
2008-06-05 16:47:50 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 16:47:50 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status -uno (advice.statusHints false)' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files not listed
|
|
|
|
EOF
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config advice.statusHints false &&
|
2010-04-23 00:30:19 +04:00
|
|
|
git status -uno >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-04-23 00:30:19 +04:00
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect << EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s -uno' '
|
|
|
|
git status -s -uno >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status -s (status.showUntrackedFiles no)' '
|
2015-03-20 13:07:15 +03:00
|
|
|
git config status.showuntrackedfiles no &&
|
2009-11-28 00:29:30 +03:00
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status -unormal' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
dir3/
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2008-06-05 12:31:19 +04:00
|
|
|
git status -unormal >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 12:31:19 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status (status.showUntrackedFiles normal)' '
|
2015-03-20 13:07:15 +03:00
|
|
|
test_config status.showuntrackedfiles normal &&
|
2008-06-05 16:47:50 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 16:47:50 +04:00
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? dir3/
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s -unormal' '
|
|
|
|
git status -s -unormal >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'status -s (status.showUntrackedFiles normal)' '
|
2015-03-20 13:07:15 +03:00
|
|
|
git config status.showuntrackedfiles normal &&
|
2009-11-28 00:29:30 +03:00
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status -uall' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
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
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2008-06-05 12:31:19 +04:00
|
|
|
git status -uall >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 16:47:50 +04:00
|
|
|
'
|
2011-04-15 00:56:14 +04:00
|
|
|
|
|
|
|
test_expect_success 'status (status.showUntrackedFiles all)' '
|
2015-03-20 13:07:15 +03:00
|
|
|
test_config status.showuntrackedfiles all &&
|
2008-06-05 16:47:50 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-06-05 12:31:19 +04:00
|
|
|
'
|
|
|
|
|
2011-02-23 02:42:13 +03:00
|
|
|
test_expect_success 'teardown dir3' '
|
|
|
|
rm -rf dir3
|
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s -uall' '
|
2015-03-20 13:10:21 +03:00
|
|
|
test_unconfig status.showuntrackedfiles &&
|
2009-11-28 00:29:30 +03:00
|
|
|
git status -s -uall >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
test_expect_success 'status -s (status.showUntrackedFiles all)' '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config status.showuntrackedfiles all &&
|
2009-11-28 00:29:30 +03:00
|
|
|
git status -s >output &&
|
|
|
|
rm -rf dir3 &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status with relative paths' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<\EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: ../dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
untracked
|
|
|
|
../dir2/modified
|
|
|
|
../dir2/untracked
|
|
|
|
../untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2009-12-08 13:12:02 +03:00
|
|
|
(cd dir1 && git status) >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2007-11-11 20:35:41 +03:00
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
2009-11-28 00:29:30 +03:00
|
|
|
M modified
|
|
|
|
A ../dir2/added
|
|
|
|
?? untracked
|
|
|
|
?? ../dir2/modified
|
|
|
|
?? ../dir2/untracked
|
|
|
|
?? ../untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s with relative paths' '
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
(cd dir1 && git status -s) >output &&
|
2009-11-28 00:29:30 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
2009-12-08 13:12:01 +03:00
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status --porcelain ignores relative paths setting' '
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
(cd dir1 && git status --porcelain) >output &&
|
2009-12-08 13:12:01 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
test_expect_success 'setup unique colors' '
|
|
|
|
|
2010-11-18 02:40:05 +03:00
|
|
|
git config status.color.untracked blue &&
|
2017-04-22 08:42:02 +03:00
|
|
|
git config status.color.branch green &&
|
|
|
|
git config status.color.localBranch yellow &&
|
|
|
|
git config status.color.remoteBranch cyan
|
2009-12-08 13:12:02 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status with color.ui' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<\EOF &&
|
|
|
|
On branch <GREEN>master<RESET>
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
<GREEN>new file: dir2/added<RESET>
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
<RED>modified: dir1/modified<RESET>
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
<BLUE>dir1/untracked<RESET>
|
|
|
|
<BLUE>dir2/modified<RESET>
|
|
|
|
<BLUE>dir2/untracked<RESET>
|
|
|
|
<BLUE>untracked<RESET>
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2017-10-03 16:43:29 +03:00
|
|
|
test_config color.ui auto &&
|
|
|
|
test_terminal git status | test_decode_color >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2009-12-08 13:12:02 +03:00
|
|
|
'
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status with color.status' '
|
|
|
|
test_config color.status auto &&
|
|
|
|
test_terminal git status | test_decode_color >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2009-12-08 13:12:02 +03:00
|
|
|
'
|
|
|
|
|
|
|
|
cat >expect <<\EOF
|
|
|
|
<RED>M<RESET> dir1/modified
|
|
|
|
<GREEN>A<RESET> dir2/added
|
|
|
|
<BLUE>??<RESET> dir1/untracked
|
|
|
|
<BLUE>??<RESET> dir2/modified
|
|
|
|
<BLUE>??<RESET> dir2/untracked
|
|
|
|
<BLUE>??<RESET> untracked
|
|
|
|
EOF
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status -s with color.ui' '
|
2009-12-08 13:12:02 +03:00
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
git config color.ui auto &&
|
|
|
|
test_terminal git status -s | test_decode_color >output &&
|
2009-12-08 13:12:02 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status -s with color.status' '
|
2009-12-08 13:12:02 +03:00
|
|
|
|
|
|
|
git config --unset color.ui &&
|
2017-10-03 16:43:29 +03:00
|
|
|
git config color.status auto &&
|
|
|
|
test_terminal git status -s | test_decode_color >output &&
|
2009-12-08 13:12:02 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2010-05-25 18:52:03 +04:00
|
|
|
cat >expect <<\EOF
|
2017-04-22 08:42:02 +03:00
|
|
|
## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>]
|
2010-05-25 18:52:03 +04:00
|
|
|
<RED>M<RESET> dir1/modified
|
|
|
|
<GREEN>A<RESET> dir2/added
|
|
|
|
<BLUE>??<RESET> dir1/untracked
|
|
|
|
<BLUE>??<RESET> dir2/modified
|
|
|
|
<BLUE>??<RESET> dir2/untracked
|
|
|
|
<BLUE>??<RESET> untracked
|
|
|
|
EOF
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status -s -b with color.status' '
|
2010-05-25 18:52:03 +04:00
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_terminal git status -s -b | test_decode_color >output &&
|
2017-05-05 21:19:32 +03:00
|
|
|
test_i18ncmp expect output
|
2010-05-25 18:52:03 +04:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status --porcelain ignores color.ui' '
|
2009-12-08 13:12:02 +03:00
|
|
|
|
|
|
|
git config --unset color.status &&
|
2017-10-03 16:43:29 +03:00
|
|
|
git config color.ui auto &&
|
|
|
|
test_terminal git status --porcelain | test_decode_color >output &&
|
2009-12-08 13:12:02 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2017-10-03 16:43:29 +03:00
|
|
|
test_expect_success TTY 'status --porcelain ignores color.status' '
|
2009-12-08 13:12:02 +03:00
|
|
|
|
|
|
|
git config --unset color.ui &&
|
2017-10-03 16:43:29 +03:00
|
|
|
git config color.status auto &&
|
|
|
|
test_terminal git status --porcelain | test_decode_color >output &&
|
2009-12-08 13:12:02 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
|
|
|
# recover unconditionally from color tests
|
|
|
|
git config --unset color.status
|
|
|
|
git config --unset color.ui
|
|
|
|
|
2012-05-08 01:09:04 +04:00
|
|
|
test_expect_success 'status --porcelain respects -b' '
|
2010-05-25 18:52:03 +04:00
|
|
|
|
|
|
|
git status --porcelain -b >output &&
|
2012-05-08 01:09:04 +04:00
|
|
|
{
|
2017-04-27 12:01:05 +03:00
|
|
|
echo "## master...upstream [ahead 1, behind 2]" &&
|
2012-05-08 01:09:04 +04:00
|
|
|
cat expect
|
|
|
|
} >tmp &&
|
|
|
|
mv tmp expect &&
|
2010-05-25 18:52:03 +04:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2007-12-08 00:26:07 +03:00
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status without relative paths' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<\EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
2007-12-08 00:26:07 +03:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config status.relativePaths false &&
|
2009-12-08 13:12:02 +03:00
|
|
|
(cd dir1 && git status) >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2007-12-08 00:26:07 +03:00
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-12-08 13:12:02 +03:00
|
|
|
cat >expect <<\EOF
|
2009-11-28 00:29:30 +03:00
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success 'status -s without relative paths' '
|
|
|
|
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config status.relativePaths false &&
|
2009-12-08 13:12:02 +03:00
|
|
|
(cd dir1 && git status -s) >output &&
|
2009-11-28 00:29:30 +03:00
|
|
|
test_cmp expect output
|
|
|
|
|
|
|
|
'
|
|
|
|
|
2009-08-15 13:27:39 +04:00
|
|
|
test_expect_success 'dry-run of partial commit excluding new file in index' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
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/
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2011-04-15 00:56:14 +04:00
|
|
|
git commit --dry-run dir1/modified >output &&
|
|
|
|
test_i18ncmp expect output
|
2008-02-14 20:18:23 +03:00
|
|
|
'
|
|
|
|
|
2010-04-02 16:27:20 +04:00
|
|
|
cat >expect <<EOF
|
2016-07-16 08:06:25 +03:00
|
|
|
:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified
|
2010-04-02 16:27:20 +04:00
|
|
|
EOF
|
2010-04-03 01:44:21 +04:00
|
|
|
test_expect_success 'status refreshes the index' '
|
2010-04-02 16:27:20 +04:00
|
|
|
touch dir2/added &&
|
|
|
|
git status &&
|
|
|
|
git diff-files >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-04-12 19:05:33 +04: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
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status submodule summary is disabled by default' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
new file: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2008-04-12 19:05:33 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-04-12 19:05:33 +04:00
|
|
|
'
|
|
|
|
|
2008-10-16 19:07:26 +04:00
|
|
|
# we expect the same as the previous test
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status --untracked-files=all does not show submodule' '
|
2008-10-16 19:07:26 +04:00
|
|
|
git status --untracked-files=all >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-04-12 19:05:33 +04:00
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
A sm
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s submodule summary is disabled by default' '
|
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
# we expect the same as the previous test
|
|
|
|
test_expect_success 'status -s --untracked-files=all does not show submodule' '
|
|
|
|
git status -s --untracked-files=all >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2008-04-12 19:05:33 +04:00
|
|
|
head=$(cd sm && git rev-parse --short=7 --verify HEAD)
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'status submodule summary' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 1 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
new file: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Submodule changes to be committed:
|
|
|
|
|
|
|
|
* 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
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2008-04-12 19:05:33 +04:00
|
|
|
git config status.submodulesummary 10 &&
|
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-04-12 19:05:33 +04:00
|
|
|
'
|
|
|
|
|
2013-09-06 21:43:07 +04:00
|
|
|
test_expect_success 'status submodule summary with status.displayCommentPrefix=false' '
|
|
|
|
strip_comments expect &&
|
|
|
|
git -c status.displayCommentPrefix=false status >output &&
|
|
|
|
test_i18ncmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' '
|
|
|
|
commit_template_commented
|
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
M dir1/modified
|
|
|
|
A dir2/added
|
|
|
|
A sm
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s submodule summary' '
|
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
2008-04-12 19:05:33 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
test_expect_success 'status submodule summary (clean submodule): commit' '
|
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2008-04-12 19:05:33 +04:00
|
|
|
no changes added to commit (use "git add" and/or "git commit -a")
|
|
|
|
EOF
|
2011-04-15 00:56:14 +04:00
|
|
|
git commit -m "commit submodule" &&
|
2008-04-12 19:05:33 +04:00
|
|
|
git config status.submodulesummary 10 &&
|
2009-08-15 13:27:39 +04:00
|
|
|
test_must_fail git commit --dry-run >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output &&
|
2009-08-15 13:27:39 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-04-12 19:05:33 +04:00
|
|
|
'
|
|
|
|
|
2009-11-28 00:29:30 +03:00
|
|
|
cat >expect <<EOF
|
|
|
|
M dir1/modified
|
|
|
|
?? dir1/untracked
|
|
|
|
?? dir2/modified
|
|
|
|
?? dir2/untracked
|
|
|
|
?? untracked
|
|
|
|
EOF
|
|
|
|
test_expect_success 'status -s submodule summary (clean submodule)' '
|
|
|
|
git status -s >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2011-05-27 00:43:21 +04:00
|
|
|
test_expect_success 'status -z implies porcelain' '
|
2011-05-27 00:43:20 +04:00
|
|
|
git status --porcelain |
|
2013-10-29 05:23:03 +04:00
|
|
|
perl -pe "s/\012/\000/g" >expect &&
|
2011-05-27 00:43:20 +04:00
|
|
|
git status -z >output &&
|
|
|
|
test_cmp expect output
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success 'commit --dry-run submodule summary (--amend)' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat >expect <<EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD^1 <file>..." to unstage)
|
|
|
|
|
|
|
|
new file: dir2/added
|
|
|
|
new file: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Submodule changes to be committed:
|
|
|
|
|
|
|
|
* 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
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2008-04-12 19:05:33 +04:00
|
|
|
git config status.submodulesummary 10 &&
|
2009-08-15 13:27:39 +04:00
|
|
|
git commit --dry-run --amend >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2008-04-12 19:05:33 +04:00
|
|
|
'
|
|
|
|
|
2010-08-07 02:09:09 +04:00
|
|
|
test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' '
|
2010-04-03 14:11:57 +04:00
|
|
|
(
|
|
|
|
chmod a-w .git &&
|
|
|
|
# make dir1/tracked stat-dirty
|
|
|
|
>dir1/tracked1 && mv -f dir1/tracked1 dir1/tracked &&
|
|
|
|
git status -s >output &&
|
|
|
|
! grep dir1/tracked output &&
|
|
|
|
# make sure "status" succeeded without writing index out
|
|
|
|
git diff-files | grep dir1/tracked
|
|
|
|
)
|
|
|
|
status=$?
|
|
|
|
chmod 775 .git
|
|
|
|
(exit $status)
|
|
|
|
'
|
|
|
|
|
2010-09-06 22:41:06 +04:00
|
|
|
(cd sm && echo > bar && git add bar && git commit -q -m 'Add bar') && git add sm
|
2010-08-06 02:39:25 +04:00
|
|
|
new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
|
|
|
|
touch .gitmodules
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat > expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
modified: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Submodule changes to be committed:
|
|
|
|
|
|
|
|
* sm $head...$new_head (1):
|
|
|
|
> Add bar
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitmodules
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2011-04-15 00:56:14 +04:00
|
|
|
echo modified sm/untracked &&
|
|
|
|
git status --ignore-submodules=untracked >output &&
|
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config diff.ignoreSubmodules dirty &&
|
2010-08-06 03:27:15 +04:00
|
|
|
git status >output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore untracked &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2013-03-25 01:06:11 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:40:48 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore untracked &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config --remove-section -f .gitmodules submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
|
|
|
|
git status --ignore-submodules=dirty >output &&
|
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config diff.ignoreSubmodules dirty &&
|
2010-08-06 03:27:15 +04:00
|
|
|
git status >output &&
|
|
|
|
! test -s actual &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore dirty &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2013-03-25 01:06:11 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:40:48 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore dirty &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
|
|
|
|
echo modified >sm/foo &&
|
|
|
|
git status --ignore-submodules=dirty >output &&
|
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore dirty &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore dirty &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat > expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
modified: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
(commit or discard the untracked or modified content in submodules)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
modified: sm (modified content)
|
|
|
|
|
|
|
|
Submodule changes to be committed:
|
|
|
|
|
|
|
|
* sm $head...$new_head (1):
|
|
|
|
> Add bar
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitmodules
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2010-06-25 18:56:47 +04:00
|
|
|
git status --ignore-submodules=untracked > output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore untracked &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore untracked &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2010-06-25 18:56:47 +04:00
|
|
|
head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
|
2013-09-06 21:43:08 +04:00
|
|
|
cat > expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
modified: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
modified: sm (new commits)
|
|
|
|
|
|
|
|
Submodule changes to be committed:
|
|
|
|
|
|
|
|
* sm $head...$new_head (1):
|
|
|
|
> Add bar
|
|
|
|
|
|
|
|
Submodules changed but not updated:
|
|
|
|
|
|
|
|
* sm $new_head...$head2 (1):
|
|
|
|
> 2nd commit
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitmodules
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
EOF
|
2010-06-25 18:56:47 +04:00
|
|
|
git status --ignore-submodules=untracked > output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore untracked &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore untracked &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
|
2010-06-25 18:56:47 +04:00
|
|
|
git status --ignore-submodules=dirty > output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore dirty &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
2010-06-25 18:56:47 +04:00
|
|
|
|
2011-04-15 00:56:14 +04:00
|
|
|
test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore dirty &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
2011-04-15 00:56:14 +04:00
|
|
|
git status >output &&
|
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2013-01-16 23:18:48 +04:00
|
|
|
cat > expect << EOF
|
|
|
|
; On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
; Your branch and 'upstream' have diverged,
|
|
|
|
; and have 2 and 2 different commits each, respectively.
|
|
|
|
; (use "git pull" to merge the remote branch into yours)
|
|
|
|
;
|
2013-01-16 23:18:48 +04:00
|
|
|
; Changes to be committed:
|
|
|
|
; (use "git reset HEAD <file>..." to unstage)
|
|
|
|
;
|
|
|
|
; modified: sm
|
|
|
|
;
|
|
|
|
; Changes not staged for commit:
|
|
|
|
; (use "git add <file>..." to update what will be committed)
|
|
|
|
; (use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
;
|
|
|
|
; modified: dir1/modified
|
|
|
|
; modified: sm (new commits)
|
|
|
|
;
|
|
|
|
; Submodule changes to be committed:
|
|
|
|
;
|
|
|
|
; * sm $head...$new_head (1):
|
|
|
|
; > Add bar
|
|
|
|
;
|
|
|
|
; Submodules changed but not updated:
|
|
|
|
;
|
|
|
|
; * sm $new_head...$head2 (1):
|
|
|
|
; > 2nd commit
|
|
|
|
;
|
|
|
|
; Untracked files:
|
|
|
|
; (use "git add <file>..." to include in what will be committed)
|
|
|
|
;
|
|
|
|
; .gitmodules
|
|
|
|
; dir1/untracked
|
|
|
|
; dir2/modified
|
|
|
|
; dir2/untracked
|
|
|
|
; untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
;
|
2013-01-16 23:18:48 +04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
test_expect_success "status (core.commentchar with submodule summary)" '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config core.commentchar ";" &&
|
2013-09-06 21:43:08 +04:00
|
|
|
git -c status.displayCommentPrefix=true status >output &&
|
2013-01-16 23:18:48 +04:00
|
|
|
test_i18ncmp expect output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success "status (core.commentchar with two chars with submodule summary)" '
|
2013-03-25 01:06:11 +04:00
|
|
|
test_config core.commentchar ";;" &&
|
2014-05-17 05:52:22 +04:00
|
|
|
test_must_fail git -c status.displayCommentPrefix=true status
|
2013-01-16 23:18:48 +04:00
|
|
|
'
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
test_expect_success "--ignore-submodules=all suppresses submodule summary" '
|
|
|
|
cat > expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2013-09-06 21:43:08 +04:00
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitmodules
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
2013-09-06 21:43:09 +04:00
|
|
|
|
2010-06-25 18:56:47 +04:00
|
|
|
no changes added to commit (use "git add" and/or "git commit -a")
|
|
|
|
EOF
|
|
|
|
git status --ignore-submodules=all > output &&
|
2011-04-15 00:56:14 +04:00
|
|
|
test_i18ncmp expect output
|
2010-06-25 18:56:47 +04:00
|
|
|
'
|
|
|
|
|
2014-04-05 20:59:03 +04:00
|
|
|
test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
|
|
|
|
cat > expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2014-04-05 20:59:03 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
modified: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files:
|
|
|
|
(use "git add <file>..." to include in what will be committed)
|
|
|
|
|
|
|
|
.gitmodules
|
|
|
|
dir1/untracked
|
|
|
|
dir2/modified
|
|
|
|
dir2/untracked
|
|
|
|
untracked
|
|
|
|
|
|
|
|
EOF
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore all &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
|
|
|
git status > output &&
|
2016-06-17 23:21:07 +03:00
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
|
|
|
|
2014-04-05 20:59:03 +04:00
|
|
|
test_expect_success '.git/config ignore=all suppresses unstaged submodule summary' '
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --add -f .gitmodules submodule.subname.ignore none &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
2010-08-06 02:39:25 +04:00
|
|
|
git config --add submodule.subname.ignore all &&
|
|
|
|
git config --add submodule.subname.path sm &&
|
|
|
|
git status > output &&
|
2016-06-17 23:21:07 +03:00
|
|
|
test_i18ncmp expect output &&
|
2010-08-06 02:40:48 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
2010-08-06 02:39:25 +04:00
|
|
|
'
|
|
|
|
|
2013-06-11 17:34:04 +04:00
|
|
|
test_expect_success 'setup of test environment' '
|
|
|
|
git config status.showUntrackedFiles no &&
|
|
|
|
git status -s >expected_short &&
|
|
|
|
git status --no-short >expected_noshort
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.short=true" same as "-s"' '
|
|
|
|
git -c status.short=true status >actual &&
|
|
|
|
test_cmp expected_short actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.short=true" weaker than "--no-short"' '
|
|
|
|
git -c status.short=true status --no-short >actual &&
|
|
|
|
test_cmp expected_noshort actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.short=false" same as "--no-short"' '
|
|
|
|
git -c status.short=false status >actual &&
|
|
|
|
test_cmp expected_noshort actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.short=false" weaker than "-s"' '
|
|
|
|
git -c status.short=false status -s >actual &&
|
|
|
|
test_cmp expected_short actual
|
|
|
|
'
|
|
|
|
|
2013-06-11 17:34:05 +04:00
|
|
|
test_expect_success '"status.branch=true" same as "-b"' '
|
|
|
|
git status -sb >expected_branch &&
|
|
|
|
git -c status.branch=true status -s >actual &&
|
|
|
|
test_cmp expected_branch actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.branch=true" different from "--no-branch"' '
|
|
|
|
git status -s --no-branch >expected_nobranch &&
|
|
|
|
git -c status.branch=true status -s >actual &&
|
|
|
|
test_must_fail test_cmp expected_nobranch actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.branch=true" weaker than "--no-branch"' '
|
|
|
|
git -c status.branch=true status -s --no-branch >actual &&
|
|
|
|
test_cmp expected_nobranch actual
|
|
|
|
'
|
|
|
|
|
2013-06-24 22:41:40 +04:00
|
|
|
test_expect_success '"status.branch=true" weaker than "--porcelain"' '
|
|
|
|
git -c status.branch=true status --porcelain >actual &&
|
|
|
|
test_cmp expected_nobranch actual
|
|
|
|
'
|
|
|
|
|
2013-06-11 17:34:05 +04:00
|
|
|
test_expect_success '"status.branch=false" same as "--no-branch"' '
|
|
|
|
git -c status.branch=false status -s >actual &&
|
|
|
|
test_cmp expected_nobranch actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.branch=false" weaker than "-b"' '
|
|
|
|
git -c status.branch=false status -sb >actual &&
|
|
|
|
test_cmp expected_branch actual
|
|
|
|
'
|
|
|
|
|
2013-06-11 17:34:04 +04:00
|
|
|
test_expect_success 'Restore default test environment' '
|
|
|
|
git config --unset status.showUntrackedFiles
|
|
|
|
'
|
|
|
|
|
2014-04-05 20:59:03 +04:00
|
|
|
test_expect_success 'git commit will commit a staged but ignored submodule' '
|
|
|
|
git config --add -f .gitmodules submodule.subname.ignore all &&
|
|
|
|
git config --add -f .gitmodules submodule.subname.path sm &&
|
|
|
|
git config --add submodule.subname.ignore all &&
|
|
|
|
git status -s --ignore-submodules=dirty >output &&
|
|
|
|
test_i18ngrep "^M. sm" output &&
|
|
|
|
GIT_EDITOR="echo hello >>\"\$1\"" &&
|
|
|
|
export GIT_EDITOR &&
|
|
|
|
git commit -uno &&
|
|
|
|
git status -s --ignore-submodules=dirty >output &&
|
|
|
|
test_i18ngrep ! "^M. sm" output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
|
|
|
|
git reset HEAD^ &&
|
|
|
|
git add sm &&
|
|
|
|
cat >expect << EOF &&
|
|
|
|
On branch master
|
2017-04-27 12:01:05 +03:00
|
|
|
Your branch and '\''upstream'\'' have diverged,
|
|
|
|
and have 2 and 2 different commits each, respectively.
|
|
|
|
(use "git pull" to merge the remote branch into yours)
|
|
|
|
|
2014-04-05 20:59:03 +04:00
|
|
|
Changes to be committed:
|
|
|
|
(use "git reset HEAD <file>..." to unstage)
|
|
|
|
|
|
|
|
modified: sm
|
|
|
|
|
|
|
|
Changes not staged for commit:
|
|
|
|
(use "git add <file>..." to update what will be committed)
|
|
|
|
(use "git checkout -- <file>..." to discard changes in working directory)
|
|
|
|
|
|
|
|
modified: dir1/modified
|
|
|
|
|
|
|
|
Untracked files not listed (use -u option to show untracked files)
|
|
|
|
EOF
|
|
|
|
git commit -uno --dry-run >output &&
|
|
|
|
test_i18ncmp expect output &&
|
|
|
|
git status -s --ignore-submodules=dirty >output &&
|
|
|
|
test_i18ngrep "^M. sm" output
|
|
|
|
'
|
|
|
|
|
2014-04-05 20:59:36 +04:00
|
|
|
test_expect_success 'git commit -m will commit a staged but ignored submodule' '
|
2014-04-05 20:59:03 +04:00
|
|
|
git commit -uno -m message &&
|
|
|
|
git status -s --ignore-submodules=dirty >output &&
|
2017-06-21 15:31:45 +03:00
|
|
|
test_i18ngrep ! "^M. sm" output &&
|
2014-04-05 20:59:03 +04:00
|
|
|
git config --remove-section submodule.subname &&
|
|
|
|
git config -f .gitmodules --remove-section submodule.subname
|
|
|
|
'
|
|
|
|
|
2017-06-18 01:30:51 +03:00
|
|
|
test_expect_success 'show stash info with "--show-stash"' '
|
|
|
|
git reset --hard &&
|
|
|
|
git stash clear &&
|
|
|
|
echo 1 >file &&
|
|
|
|
git add file &&
|
|
|
|
git stash &&
|
|
|
|
git status >expected_default &&
|
|
|
|
git status --show-stash >expected_with_stash &&
|
|
|
|
test_i18ngrep "^Your stash currently has 1 entry$" expected_with_stash
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'no stash info with "--show-stash --no-show-stash"' '
|
|
|
|
git status --show-stash --no-show-stash >expected_without_stash &&
|
|
|
|
test_cmp expected_default expected_without_stash
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.showStash=false" weaker than "--show-stash"' '
|
|
|
|
git -c status.showStash=false status --show-stash >actual &&
|
|
|
|
test_cmp expected_with_stash actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' '
|
|
|
|
git -c status.showStash=true status --no-show-stash >actual &&
|
|
|
|
test_cmp expected_without_stash actual
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'no additionnal info if no stash entries' '
|
|
|
|
git stash clear &&
|
|
|
|
git -c status.showStash=true status >actual &&
|
|
|
|
test_cmp expected_without_stash actual
|
|
|
|
'
|
|
|
|
|
2017-06-21 21:16:14 +03:00
|
|
|
test_expect_success '"No commits yet" should be noted in status output' '
|
|
|
|
git checkout --orphan empty-branch-1 &&
|
|
|
|
git status >output &&
|
|
|
|
test_i18ngrep "No commits yet" output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"No commits yet" should not be noted in status output' '
|
|
|
|
git checkout --orphan empty-branch-2 &&
|
|
|
|
test_commit test-commit-1 &&
|
|
|
|
git status >output &&
|
|
|
|
test_i18ngrep ! "No commits yet" output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"Initial commit" should be noted in commit template' '
|
|
|
|
git checkout --orphan empty-branch-3 &&
|
|
|
|
touch to_be_committed_1 &&
|
|
|
|
git add to_be_committed_1 &&
|
|
|
|
git commit --dry-run >output &&
|
|
|
|
test_i18ngrep "Initial commit" output
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success '"Initial commit" should not be noted in commit template' '
|
|
|
|
git checkout --orphan empty-branch-4 &&
|
|
|
|
test_commit test-commit-2 &&
|
|
|
|
touch to_be_committed_2 &&
|
|
|
|
git add to_be_committed_2 &&
|
|
|
|
git commit --dry-run >output &&
|
|
|
|
test_i18ngrep ! "Initial commit" output
|
|
|
|
'
|
|
|
|
|
git: add --no-optional-locks option
Some tools like IDEs or fancy editors may periodically run
commands like "git status" in the background to keep track
of the state of the repository. Some of these commands may
refresh the index and write out the result in an
opportunistic way: if they can get the index lock, then they
update the on-disk index with any updates they find. And if
not, then their in-core refresh is lost and just has to be
recomputed by the next caller.
But taking the index lock may conflict with other operations
in the repository. Especially ones that the user is doing
themselves, which _aren't_ opportunistic. In other words,
"git status" knows how to back off when somebody else is
holding the lock, but other commands don't know that status
would be happy to drop the lock if somebody else wanted it.
There are a couple possible solutions:
1. Have some kind of "pseudo-lock" that allows other
commands to tell status that they want the lock.
This is likely to be complicated and error-prone to
implement (and maybe even impossible with just
dotlocks to work from, as it requires some
inter-process communication).
2. Avoid background runs of commands like "git status"
that want to do opportunistic updates, preferring
instead plumbing like diff-files, etc.
This is awkward for a couple of reasons. One is that
"status --porcelain" reports a lot more about the
repository state than is available from individual
plumbing commands. And two is that we actually _do_
want to see the refreshed index. We just don't want to
take a lock or write out the result. Whereas commands
like diff-files expect us to refresh the index
separately and write it to disk so that they can depend
on the result. But that write is exactly what we're
trying to avoid.
3. Ask "status" not to lock or write the index.
This is easy to implement. The big downside is that any
work done in refreshing the index for such a call is
lost when the process exits. So a background process
may end up re-hashing a changed file multiple times
until the user runs a command that does an index
refresh themselves.
This patch implements the option 3. The idea (and the test)
is largely stolen from a Git for Windows patch by Johannes
Schindelin, 67e5ce7f63 (status: offer *not* to lock the
index and update it, 2016-08-12). The twist here is that
instead of making this an option to "git status", it becomes
a "git" option and matching environment variable.
The reason there is two-fold:
1. An environment variable is carried through to
sub-processes. And whether an invocation is a
background process or not should apply to the whole
process tree. So you could do "git --no-optional-locks
foo", and if "foo" is a script or alias that calls
"status", you'll still get the effect.
2. There may be other programs that want the same
treatment.
I've punted here on finding more callers to convert,
since "status" is the obvious one to call as a repeated
background job. But "git diff"'s opportunistic refresh
of the index may be a good candidate.
The test is taken from 67e5ce7f63, and it's worth repeating
Johannes's explanation:
Note that the regression test added in this commit does
not *really* verify that no index.lock file was written;
that test is not possible in a portable way. Instead, we
verify that .git/index is rewritten *only* when `git
status` is run without `--no-optional-locks`.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-09-27 09:54:30 +03:00
|
|
|
test_expect_success '--no-optional-locks prevents index update' '
|
|
|
|
test-chmtime =1234567890 .git/index &&
|
|
|
|
git --no-optional-locks status &&
|
|
|
|
test-chmtime -v +0 .git/index >out &&
|
|
|
|
grep ^1234567890 out &&
|
|
|
|
git status &&
|
|
|
|
test-chmtime -v +0 .git/index >out &&
|
|
|
|
! grep ^1234567890 out
|
|
|
|
'
|
|
|
|
|
2007-11-11 20:35:41 +03:00
|
|
|
test_done
|