forked from git/git
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Teach git status to show ignored directories when showing all untracked files #1243
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#!/bin/sh | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
# | ||
# | ||
|
||
test_description='git status collapse ignored' | ||
|
||
. ./test-lib.sh | ||
|
||
|
||
cat >.gitignore <<\EOF | ||
*.ign | ||
ignored_dir/ | ||
!*.unignore | ||
EOF | ||
|
||
# commit initial ignore file | ||
test_expect_success 'setup initial commit and ignore file' ' | ||
git add . && | ||
test_tick && | ||
git commit -m "Initial commit" | ||
' | ||
|
||
cat >expect <<\EOF | ||
? expect | ||
? output | ||
! dir/ignored/ignored_1.ign | ||
! dir/ignored/ignored_2.ign | ||
! ignored/ignored_1.ign | ||
! ignored/ignored_2.ign | ||
EOF | ||
|
||
# Test status behavior on folder with ignored files | ||
test_expect_success 'setup folder with ignored files' ' | ||
mkdir -p ignored dir/ignored && | ||
touch ignored/ignored_1.ign ignored/ignored_2.ign \ | ||
dir/ignored/ignored_1.ign dir/ignored/ignored_2.ign | ||
' | ||
|
||
test_expect_success 'Verify behavior of status on folders with ignored files' ' | ||
test_when_finished "git clean -fdx" && | ||
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output && | ||
test_i18ncmp expect output | ||
' | ||
|
||
# Test status bahavior on folder with tracked and ignored files | ||
cat >expect <<\EOF | ||
? expect | ||
? output | ||
! dir/tracked_ignored/ignored_1.ign | ||
! dir/tracked_ignored/ignored_2.ign | ||
! tracked_ignored/ignored_1.ign | ||
! tracked_ignored/ignored_2.ign | ||
EOF | ||
|
||
test_expect_success 'setup folder with tracked & ignored files' ' | ||
mkdir -p tracked_ignored dir/tracked_ignored && | ||
touch tracked_ignored/tracked_1 tracked_ignored/tracked_2 \ | ||
tracked_ignored/ignored_1.ign tracked_ignored/ignored_2.ign \ | ||
dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 \ | ||
dir/tracked_ignored/ignored_1.ign dir/tracked_ignored/ignored_2.ign && | ||
|
||
git add tracked_ignored/tracked_1 tracked_ignored/tracked_2 \ | ||
dir/tracked_ignored/tracked_1 dir/tracked_ignored/tracked_2 && | ||
test_tick && | ||
git commit -m "commit tracked files" | ||
' | ||
|
||
test_expect_success 'Verify status on folder with tracked & ignored files' ' | ||
test_when_finished "git clean -fdx && git reset HEAD~1 --hard" && | ||
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output && | ||
test_i18ncmp expect output | ||
' | ||
|
||
|
||
# Test status behavior on folder with untracked and ignored files | ||
cat >expect <<\EOF | ||
? dir/untracked_ignored/untracked_1 | ||
? dir/untracked_ignored/untracked_2 | ||
? expect | ||
? output | ||
? untracked_ignored/untracked_1 | ||
? untracked_ignored/untracked_2 | ||
! dir/untracked_ignored/ignored_1.ign | ||
! dir/untracked_ignored/ignored_2.ign | ||
! untracked_ignored/ignored_1.ign | ||
! untracked_ignored/ignored_2.ign | ||
EOF | ||
|
||
test_expect_success 'setup folder with tracked & ignored files' ' | ||
mkdir -p untracked_ignored dir/untracked_ignored && | ||
touch untracked_ignored/untracked_1 untracked_ignored/untracked_2 \ | ||
untracked_ignored/ignored_1.ign untracked_ignored/ignored_2.ign \ | ||
dir/untracked_ignored/untracked_1 dir/untracked_ignored/untracked_2 \ | ||
dir/untracked_ignored/ignored_1.ign dir/untracked_ignored/ignored_2.ign | ||
' | ||
|
||
test_expect_success 'Verify status on folder with tracked & ignored files' ' | ||
test_when_finished "git clean -fdx" && | ||
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output && | ||
test_i18ncmp expect output | ||
' | ||
|
||
# Test status behavior on ignored folder | ||
cat >expect <<\EOF | ||
? expect | ||
? output | ||
! ignored_dir/ | ||
EOF | ||
|
||
test_expect_success 'setup folder with tracked & ignored files' ' | ||
mkdir ignored_dir && | ||
touch ignored_dir/ignored_1 ignored_dir/ignored_2 \ | ||
ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign | ||
' | ||
|
||
test_expect_success 'Verify status on folder with tracked & ignored files' ' | ||
test_when_finished "git clean -fdx" && | ||
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output && | ||
test_i18ncmp expect output | ||
' | ||
|
||
# Test status behavior on ignored folder with tracked file | ||
cat >expect <<\EOF | ||
? expect | ||
? output | ||
! ignored_dir/ignored_1 | ||
! ignored_dir/ignored_1.ign | ||
! ignored_dir/ignored_2 | ||
! ignored_dir/ignored_2.ign | ||
EOF | ||
|
||
test_expect_success 'setup folder with tracked & ignored files' ' | ||
mkdir ignored_dir && | ||
touch ignored_dir/ignored_1 ignored_dir/ignored_2 \ | ||
ignored_dir/ignored_1.ign ignored_dir/ignored_2.ign \ | ||
ignored_dir/tracked && | ||
git add -f ignored_dir/tracked && | ||
test_tick && | ||
git commit -m "Force add file in ignored directory" | ||
' | ||
|
||
test_expect_success 'Verify status on folder with tracked & ignored files' ' | ||
test_when_finished "git clean -fdx && git reset HEAD~1 --hard" && | ||
git status --porcelain=v2 --ignored --untracked-files=all --show-ignored-directory >output && | ||
test_i18ncmp expect output | ||
' | ||
|
||
test_done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as off-topic.
Sorry, something went wrong.