git status --ignored
This looks like a bug in git 1.7.4.1.
git status --ignored does not show my ignored files and directories. git status -h suggests it should. git status --ignored -h does show my ignored files and directories.
Also, git help status does not mention the --ignored switch.
Quoted 5 lines · Andrew Spiers
This looks like a bug in git 1.7.4.1.
git status --ignored does not show my ignored files and directories. git status -h suggests it should.
git status --ignored -h does show my ignored files and directories.
Does not reproduce for me. With --ignored (with or without -s), I see all the dot-o files that are ignored by .gitignore rules that are usually omitted from status output without --ignored.
$ make >/dev/null 2>&1 $ rungit v1.7.3 status | grep -F git.o $ rungit v1.7.3 status --ignored | grep -F git.o # git.o $ rungit v1.7.3 status -s --ignored | grep -F git.o !! git.o
The same for v1.7.4.5 or more recent versions. I am not inclined to build and install v1.7.4.1 to test, as I do not think it is likely that the particular version is bad. It is more likely that there is something wrong with your particular setting or expectation. E.g. already tracking a path that would match .gitignore rule, and expecting that such a path is shown, even though it is not "ignored".
Quoted 1 line
Also, git help status does not mention the --ignored switch.
That may be true; patches welcome.
Quoted 12 lines · Junio C Hamano
Quoted 5 lines · Andrew Spiers
This looks like a bug in git 1.7.4.1.
git status --ignored does not show my ignored files and directories. git status -h suggests it should.
git status --ignored -h does show my ignored files and directories.Does not reproduce for me. With --ignored (with or without -s), I see all the dot-o files that are ignored by .gitignore rules that are usually omitted from status output without --ignored.
Quoted 6 lines
$ make >/dev/null 2>&1 $ rungit v1.7.3 status | grep -F git.o $ rungit v1.7.3 status --ignored | grep -F git.o # git.o $ rungit v1.7.3 status -s --ignored | grep -F git.o !! git.o
I can reproduce here. The faulty logic means the bug only shows when you actually have no real untracked files. You should keep your git directory cleaner. ;)
-- >8 --
Subject: [PATCH] status: fix bug with missing --ignore files
Commit 1b908b6 (wt-status: rename and restructure status-print-untracked, 2010-04-10) converted the wt_status_print_untracked function into wt_status_print_other, taking a string_list of either untracked or ignored items to print. However, the "nothing to show" early return still checked the wt_status->untracked list instead of the passed-in list.
That meant that if we had ignored items to show, but no untracked items, we would erroneously exit early and fail to show the ignored items.
--- wt-status.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
wt-status.c +1 -1
@@ -642,7 +642,7 @@ static void wt_status_print_other(struct wt_status *s,int i;struct strbuf buf =STRBUF_INIT ; -if (!s->untracked.nr) +if (!l->nr)return ;wt_status_print_other_header (s, what, how);
Signature · 1 line
1.7.6.rc0.34.gc8c48c.dirty
Quoted 3 lines · Jeff King
That meant that if we had ignored items to show, but no untracked items, we would erroneously exit early and fail to show the ignored items.
BTW, we could probably use some tests for "status --ignore". I'll leave that to you as penance for your bug, if you want them. :)
-Peff
Quoted 3 lines · Jeff King
I can reproduce here. The faulty logic means the bug only shows when you actually have no real untracked files. You should keep your git directory cleaner. ;)
Ok.
-- >8 --
Subject: [PATCH] git status --ignored: tests and docs
--- Documentation/git-status.txt | 6 ++++ t/t7508-status.sh | 64 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 0 deletions(-)
Documentation/git-status.txt +6 -0
@@ -49,6 +49,9 @@ See linkgit:git-config[1] for configuration variable used to change the default for when the option is not specified. +--ignored:: + Show ignored files as well. + -z:: Terminate entries with NUL, instead of LF. This implies the `--porcelain` output format if no other format is given.
@@ -80,6 +83,8 @@ shows the status of stage #3 (i.e. theirs). For entries that do not have conflicts, `X` shows the status of the index, and `Y` shows the status of the work tree. For untracked paths, `XY` are `??`. +For ignored paths, `XY` are `!!`; they are shown only when the `--ignored` +option is in effect. X Y Meaning -------------------------------------------------
@@ -102,6 +107,7 @@ and `Y` shows the status of the work tree. For untracked paths, `XY` are U U unmerged, both modified ------------------------------------------------- ? ? untracked + ! ! ignored -------------------------------------------------
t/t7508-status.sh +64 -0
70 lines not on this page · raw message
Signature · 1 line
1.7.6.rc0.98.gc12085
Review
Quoted 13 lines · Junio C Hamano
(quoted diff) +13
-0+ cat >expect <<-\EOF && + M dir1/modified + A dir2/added + ?? dir2/modified + !! .gitignore + !! dir1/untracked + !! dir2/untracked + !! expect + !! output + !! untracked + EOF + git status -s --ignored >output && + test_cmp expect output
Unfortunately this does not actually show the bug, as the short format takes a different code path that was not broken.
I have mixed feelings about putting the whole long format in a test vector, as all of the human-readable bits are supposed to be allowed to change. And I know that tests are only partially about demonstrating a particular bug, and more about codifying the behavior we want so future changes don't break it. But it is nice to exercise that code path, and it doesn't change all that much, so maybe it is worth doing. Squashable patch below. Throw it out if you don't agree.
Quoted 1 line
+test_expect_success 'status with gitignore' '
It took me a minute to figure out what was different between the two tests with the same title. Maybe calling them "status with gitignore (untracked files present)" and "status with gitignore (no untracked files)" would help future readers.
---
t/t7508-status.sh +57 -0
@@ -115,6 +115,36 @@ test_expect_success 'status with gitignore' ' EOF git status -s --ignored >output && test_cmp 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) + # (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 + # Ignored files: + # (use "git add -f <file>..." to include in what will be committed) + # + # .gitignore + # dir1/untracked + # dir2/untracked + # expect + # output + # untracked + EOF + git status --ignored >output && + test_cmp expect output ' test_expect_success 'status with gitignore' '
@@ -146,6 +176,33 @@ test_expect_success 'status with gitignore' ' EOF git status -s --ignored >output && test_cmp 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) + # (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 + # output + # untracked + EOF + git status --ignored >output && + test_cmp expect output ' rm -f .gitignore
Quoted 2 lines · Jeff King
it doesn't change all that much, so maybe it is worth doing. Squashable patch below.
Thanks.