All of lore.kernel.org
 help / color / mirror / Atom feed
* git status --ignored
@ 2011-06-02  4:34 Andrew Spiers
  2011-06-02  5:13 ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Spiers @ 2011-06-02  4:34 UTC (permalink / raw)
  To: git

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.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02  4:34 git status --ignored Andrew Spiers
@ 2011-06-02  5:13 ` Junio C Hamano
  2011-06-02  5:54   ` Jeff King
  0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2011-06-02  5:13 UTC (permalink / raw)
  To: Andrew Spiers; +Cc: git

Andrew Spiers <aspiers@vpac.org> writes:

> 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".

> Also, git help status does not mention the --ignored switch.

That may be true; patches welcome.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02  5:13 ` Junio C Hamano
@ 2011-06-02  5:54   ` Jeff King
  2011-06-02  5:57     ` Jeff King
  2011-06-02 16:08     ` Junio C Hamano
  0 siblings, 2 replies; 8+ messages in thread
From: Jeff King @ 2011-06-02  5:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andrew Spiers, git

On Wed, Jun 01, 2011 at 10:13:55PM -0700, Junio C Hamano wrote:

> Andrew Spiers <aspiers@vpac.org> writes:
> 
> > 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

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.

Signed-off-by: Jeff King <peff@peff.net>
---
 wt-status.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index 9f4e0ba..0237772 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -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);
-- 
1.7.6.rc0.34.gc8c48c.dirty

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02  5:54   ` Jeff King
@ 2011-06-02  5:57     ` Jeff King
  2011-06-02 16:08     ` Junio C Hamano
  1 sibling, 0 replies; 8+ messages in thread
From: Jeff King @ 2011-06-02  5:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andrew Spiers, git

On Thu, Jun 02, 2011 at 01:54:49AM -0400, Jeff King wrote:

> 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02  5:54   ` Jeff King
  2011-06-02  5:57     ` Jeff King
@ 2011-06-02 16:08     ` Junio C Hamano
  2011-06-02 17:20       ` Jeff King
  1 sibling, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2011-06-02 16:08 UTC (permalink / raw)
  To: Jeff King; +Cc: Andrew Spiers, git

Jeff King <peff@peff.net> writes:

> 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

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Documentation/git-status.txt |    6 ++++
 t/t7508-status.sh            |   64 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)

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..b47aad8 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -86,6 +86,70 @@ 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
+'
+
+test_expect_success 'status with gitignore' '
+	{
+		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
+'
+
+rm -f .gitignore
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed:
-- 
1.7.6.rc0.98.gc12085

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02 16:08     ` Junio C Hamano
@ 2011-06-02 17:20       ` Jeff King
  2011-06-02 18:30         ` Junio C Hamano
  0 siblings, 1 reply; 8+ messages in thread
From: Jeff King @ 2011-06-02 17:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Andrew Spiers, git

On Thu, Jun 02, 2011 at 09:08:18AM -0700, Junio C Hamano wrote:

> +	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.

> +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.

---
diff --git a/t/t7508-status.sh b/t/t7508-status.sh
index b47aad8..957c1e3 100755
--- a/t/t7508-status.sh
+++ b/t/t7508-status.sh
@@ -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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: git status --ignored
  2011-06-02 17:20       ` Jeff King
@ 2011-06-02 18:30         ` Junio C Hamano
  0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2011-06-02 18:30 UTC (permalink / raw)
  To: Jeff King; +Cc: Andrew Spiers, git

Jeff King <peff@peff.net> writes:

> it doesn't change all that much, so maybe it is worth doing. Squashable
> patch below.

Thanks.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* git status --ignored
@ 2011-06-02  4:43 Andrew Spiers
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Spiers @ 2011-06-02  4:43 UTC (permalink / raw)
  To: git

***git status --ignored -h does show my ignored files and directories.
sorry, that should read:
git status --ignored -s does show my ignored files and directories.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-06-02 18:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-02  4:34 git status --ignored Andrew Spiers
2011-06-02  5:13 ` Junio C Hamano
2011-06-02  5:54   ` Jeff King
2011-06-02  5:57     ` Jeff King
2011-06-02 16:08     ` Junio C Hamano
2011-06-02 17:20       ` Jeff King
2011-06-02 18:30         ` Junio C Hamano
2011-06-02  4:43 Andrew Spiers

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.