git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karsten Blees <karsten.blees@gmail.com>
To: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Git List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Erik Faye-Lund <kusmabite@gmail.com>,
	Robert Zeh <robert.allan.zeh@gmail.com>,
	Duy Nguyen <pclouds@gmail.com>,
	Antoine Pelisse <apelisse@gmail.com>,
	Adam Spiers <git@adamspiers.org>
Subject: Re: [PATCH v2 03/14] dir.c: git-status --ignored: don't list empty ignored directories
Date: Wed, 17 Apr 2013 02:31:06 +0200	[thread overview]
Message-ID: <516DED4A.5050800@gmail.com> (raw)
In-Reply-To: <CALkWK0mG6bzWu7dqdP1mBe+AZfUDK=Mx4+ZkDOc2saXr3gBsUQ@mail.gmail.com>

Am 16.04.2013 19:48, schrieb Ramkumar Ramachandra:
> Karsten Blees wrote:
>> 'git-status --ignored' lists ignored tracked directories without any
>> ignored files if a tracked file happens to match an exclude pattern.
> 
> Here, I have:
> 
>     quux/
>         bar
>         baz/
>             foo
> 
> So, quux is an ignored tracked directory.  bar is tracked, but matches
> an ignore pattern.  Currently, git status --ignored lists quux/.  I'm
> confused.
> 

The crucial part is 'without any ignored files'. So if you 'rm quux/baz/foo' or 'git-add -f quux/baz/foo', you get this:

1) git-status --ignored -uall: <empty>
2) git-status --ignored -unormal: quux/

In case 2), quux/ is listed as ignored even though there are no ignored files and the DIR_HIDE_EMPTY_DIRECTORIES flag should kick in.

>> Always exclude tracked files.
> 
> "exclude" it from the 'git status --ignored' output, I presume?
> There's already an _exclude_ pattern in your previous sentence, so you
> can see why the reader might be confused about what you're talking
> about.
> 

I see, but "Always *ignore* tracked files" is also ambiguous. Suggestions?

>> diff --git a/dir.c b/dir.c
>> index 7c9bc9c..fd1f088 100644
>> --- a/dir.c
>> +++ b/dir.c
>> @@ -1109,16 +1109,13 @@ static int treat_file(struct dir_struct *dir, struct strbuf *path, int exclude,
>>         struct path_exclude_check check;
>>         int exclude_file = 0;
>>
>> +       /* Always exclude indexed files */
>> +       if (index_name_exists(&the_index, path->buf, path->len, ignore_case))
>> +               return 1;
>> +
>>         if (exclude)
>>                 exclude_file = !(dir->flags & DIR_SHOW_IGNORED);
>>         else if (dir->flags & DIR_SHOW_IGNORED) {
>> -               /* Always exclude indexed files */
>> -               struct cache_entry *ce = index_name_exists(&the_index,
>> -                   path->buf, path->len, ignore_case);
>> -
>> -               if (ce)
>> -                       return 1;
>> -
> 
> Okay, so you just moved this segment outside the else if()
> conditional.  Can you explain what the old logic was doing, and what
> the rationale for it was?
> 

Quoting Antoine's patch from January:
+		/*
+		 * Optimization:
+		 * Don't spend time on indexed files, they won't be
+		 * added to the list anyway
+		 */

In other words: don't do the (expensive) recursive is_path_excluded check if the file will be dropped later anyway (see the additional 'cache_name_is_other' checks in wt_status.c::wt_status_collect_untracked and builtin/ls-files.c::show_other_files).

In the DIR_SHOW_OTHER_DIRECTORIES case, we use read_directory_recursive to just *check* for ignored / untracked files, all within dir.c. So the results must be correct *here*, we cannot rely on some other modules to fix up incorrect files later.

>> diff --git a/t/t7061-wtstatus-ignore.sh b/t/t7061-wtstatus-ignore.sh
>> index 4ece129..28b7d95 100755
>> --- a/t/t7061-wtstatus-ignore.sh
>> +++ b/t/t7061-wtstatus-ignore.sh
>> @@ -122,10 +122,34 @@ cat >expected <<\EOF
>>  ?? .gitignore
>>  ?? actual
>>  ?? expected
>> +EOF
>> +
>> +test_expect_success 'status ignored tracked directory and ignored file with --ignore' '
>> +       echo "committed" >>.gitignore &&
>> +       git status --porcelain --ignored >actual &&
>> +       test_cmp expected actual
>> +'
> 
> Um, didn't really get this one.  You have three untracked files, and
> git status seems to be showing them fine.  What am I missing?
> 

We have this:

	tracked/
		committed

.gitignore:
tracked
committed

Both the directory and tracked file match an exclude pattern. There are no untracked ignored files, yet before this patch, git-status --ignored would list tracked/ as ignored directory.

>> +cat >expected <<\EOF
>> +?? .gitignore
>> +?? actual
>> +?? expected
>> +EOF
>> +
>> +test_expect_success 'status ignored tracked directory and ignored file with --ignore -u' '
>> +       git status --porcelain --ignored -u >actual &&
>> +       test_cmp expected actual
>> +'
> 
> I didn't understand why you're invoking -u here (doesn't it imply
> "all", as opposed to "normal" when unspecified?).  There are really no
> directories, so I don't know what I'm expected to see.
> 
>> +cat >expected <<\EOF
>> +?? .gitignore
>> +?? actual
>> +?? expected
>>  !! tracked/
>>  EOF
>>
>>  test_expect_success 'status ignored tracked directory and uncommitted file with --ignore' '
>> +       echo "tracked" >.gitignore &&
>>         : >tracked/uncommitted &&
>>         git status --porcelain --ignored >actual &&
>>         test_cmp expected actual
> 
> Didn't we test this in the last patch?  Okay, I'm completely confused now.
> 

'echo "tracked" >.gitignore' reverts the 'echo "committed" >>.gitignore' from above.

  reply	other threads:[~2013-04-17  0:31 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-18 20:28 [PATCH 0/8] Improve git-status --ignored Karsten Blees
2013-03-19  4:08 ` Junio C Hamano
2013-03-19  5:20   ` Duy Nguyen
2013-03-19 10:48     ` Karsten Blees
2013-03-19 14:48     ` Junio C Hamano
2013-03-19 15:58       ` Duy Nguyen
2013-04-15 19:04 ` [PATCH v2 00/14] " Karsten Blees
2013-04-15 19:05   ` [PATCH v2 01/14] dir.c: git-status --ignored: don't drop ignored directories Karsten Blees
2013-04-16 17:33     ` Ramkumar Ramachandra
2013-04-17  0:31       ` Karsten Blees
2013-04-15 19:06   ` [PATCH v2 02/14] dir.c: git-status --ignored: don't list files in " Karsten Blees
2013-04-16  9:57     ` [PATCH] read_revisions_from_stdin: make copies for handle_revision_arg Thomas Rast
2013-04-16 18:17       ` Junio C Hamano
2013-04-15 19:07   ` [PATCH v2 03/14] dir.c: git-status --ignored: don't list empty ignored directories Karsten Blees
2013-04-16 17:48     ` Ramkumar Ramachandra
2013-04-17  0:31       ` Karsten Blees [this message]
2013-04-15 19:08   ` [PATCH v2 04/14] dir.c: git-ls-files --directories: don't hide empty directories Karsten Blees
2013-04-15 19:08   ` [PATCH v2 05/14] dir.c: git-status --ignored: don't list empty directories as ignored Karsten Blees
2013-04-15 19:09   ` [PATCH v2 06/14] dir.c: make 'git-status --ignored' work within leading directories Karsten Blees
2013-04-15 19:10   ` [PATCH v2 07/14] dir.c: git-clean -d -X: don't delete tracked directories Karsten Blees
2013-04-15 19:11   ` [PATCH v2 08/14] dir.c: factor out parts of last_exclude_matching for later reuse Karsten Blees
2013-04-15 19:11   ` [PATCH v2 09/14] dir.c: move prep_exclude Karsten Blees
2013-04-15 19:12   ` [PATCH v2 10/14] dir.c: unify is_excluded and is_path_excluded APIs Karsten Blees
2013-04-15 21:35     ` Junio C Hamano
2013-04-15 19:12   ` [PATCH v2 11/14] dir.c: replace is_path_excluded with now equivalent is_excluded API Karsten Blees
2013-04-15 19:13   ` [PATCH v2 12/14] dir.c: git-status: avoid is_excluded checks for tracked files Karsten Blees
2013-04-15 19:14   ` [PATCH v2 13/14] dir.c: git-status --ignored: don't scan the work tree three times Karsten Blees
2013-04-15 19:15   ` [PATCH v2 14/14] dir.c: git-status --ignored: don't scan the work tree twice Karsten Blees
2013-04-15 19:23   ` [PATCH v2 00/14] Improve git-status --ignored Junio C Hamano
2013-04-15 19:33     ` Junio C Hamano
2013-04-15 20:06       ` Karsten Blees
2013-04-15 20:25         ` Junio C Hamano
2013-04-17 19:50           ` Karsten Blees
2013-04-17 22:03             ` Junio C Hamano
2013-04-17 19:50           ` [PATCH v2-pu 11/14] dir.c: replace is_path_excluded with now equivalent is_excluded API Karsten Blees
2013-04-17 19:51           ` [PATCH v2-pu 14/14] dir.c: git-status --ignored: don't scan the work tree twice Karsten Blees

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=516DED4A.5050800@gmail.com \
    --to=karsten.blees@gmail.com \
    --cc=apelisse@gmail.com \
    --cc=artagnon@gmail.com \
    --cc=git@adamspiers.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kusmabite@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=robert.allan.zeh@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).