From 1282988b4d3d37926050a5f21ad4f7516d9a2d7f Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 2 Jun 2011 01:54:49 -0400 Subject: 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. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/wt-status.c b/wt-status.c index 7bda995..160e841 100644 --- a/wt-status.c +++ b/wt-status.c @@ -551,7 +551,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); -- cgit v0.10.2-6-g49f6 From 150b493ad42757b60eacbf98ff11982456481982 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 2 Jun 2011 09:07:11 -0700 Subject: git status --ignored: tests and docs Helped-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 1cab91b..b663e51 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -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 ------------------------------------------------- diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 556d0fa..4856f9e 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -86,6 +86,127 @@ test_expect_success 'status -s (2)' ' ' +test_expect_success 'status with gitignore' ' + { + echo ".gitignore" && + echo "expect" && + 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 + !! output + !! untracked + EOF + git status -s --ignored >output && + test_cmp expect output && + + cat >expect <<-\EOF && + # On branch master + # Changes to be committed: + # (use "git reset HEAD ..." to unstage) + # + # new file: dir2/added + # + # Changed but not updated: + # (use "git add ..." to update what will be committed) + # (use "git checkout -- ..." to discard changes in working directory) + # + # modified: dir1/modified + # + # Untracked files: + # (use "git add ..." to include in what will be committed) + # + # dir2/modified + # Ignored files: + # (use "git add -f ..." 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 (nothing untracked)' ' + { + echo ".gitignore" && + echo "expect" && + 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 + !! output + !! untracked + EOF + git status -s --ignored >output && + test_cmp expect output && + + cat >expect <<-\EOF && + # On branch master + # Changes to be committed: + # (use "git reset HEAD ..." to unstage) + # + # new file: dir2/added + # + # Changed but not updated: + # (use "git add ..." to update what will be committed) + # (use "git checkout -- ..." to discard changes in working directory) + # + # modified: dir1/modified + # + # Ignored files: + # (use "git add -f ..." 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 + cat >expect <