Re: [PATCH v2] status: always report ignored tracked directories

2013-01-07 Thread Torsten Bögershausen
On 06.01.13 23:09, Antoine Pelisse wrote:
[snip]
 Signed-off-by: Antoine Pelisse apeli...@gmail.com
 ---
  dir.c | 9 +++--
  1 file changed, 3 insertions(+), 6 deletions(-)

 diff --git a/dir.c b/dir.c
 index 9b80348..f836590 100644
 --- a/dir.c
 +++ b/dir.c
 @@ -672,7 +672,8 @@ static struct dir_entry *dir_entry_new(const char 
 *pathname, int len)

  static struct dir_entry *dir_add_name(struct dir_struct *dir, const char 
 *pathname, int len)
  {
 - if (cache_name_exists(pathname, len, ignore_case))
 + if (!(dir-flags  DIR_SHOW_IGNORED) 
 + cache_name_exists(pathname, len, ignore_case))
   return NULL;

   ALLOC_GROW(dir-entries, dir-nr+1, dir-alloc);
 @@ -877,11 +878,7 @@ static int treat_file(struct dir_struct *dir, struct 
 strbuf *path, int exclude,
   if (exclude)
   exclude_file = !(dir-flags  DIR_SHOW_IGNORED);
   else if (dir-flags  DIR_SHOW_IGNORED) {
 - /*
 -  * Optimization:
 -  * Don't spend time on indexed files, they won't be
 -  * added to the list anyway
 -  */
 + /* Always exclude indexed files */
   struct cache_entry *ce = index_name_exists(the_index,
   path-buf, path-len, ignore_case);

 --
 1.7.12.4.3.g90f5e2d

The bad news: the patch does not apply.
The good news: t7061 passes on pu,
and dir.c seems to be changes as needed:

commit 1f4e17c6c9833f17dc6bbf045f8a8d6378dcb417
Merge: dee1fa4 cc37e5b
Author: Junio C Hamano gits...@pobox.com
Date: Sun Jan 6 23:46:29 2013 -0800

Merge branch 'nd/parse-pathspec' into pu

which comes from Duy:

commit cc37e5bf18ca11d9a884bddfebcdff61df3e6279
Author: Nguyễn Thái Ngọc Duy pclo...@gmail.com
Date: Sun Jan 6 13:21:08 2013 +0700

Convert more init_pathspec() to parse_pathspec()



--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] status: always report ignored tracked directories

2013-01-07 Thread Junio C Hamano
Antoine Pelisse apeli...@gmail.com writes:

First, thanks for working on this.

The explanation is a bit confusing, especially for people like me,
as it does not make it clear that there are two kinds of paths in
the index.  Files can be added to the index (git add and then
shown via ls-files) and these are what we usually call files in
the index.  But there is a separate name hash that keeps track of
paths the index knows about in play, and that is what is discussed
in the description.

 Tracked directories (i.e. directories containing tracked files)
 that are ignored must be reported as ignored if they contain
 untracked files.

 Currently, files in the index can't be reported as ignored and are
 automatically dropped from the list:

file in the index will never be ignored, period.  Some paths the
index knows about, namely, directory names in name hash, may need to
be reported as ignored.

It is not clear what list the above dropped from the list refers
to.  The list of paths that becomes the result of status?

  - When core.ignorecase is false, directories (which are not directly
  tracked) are not listed as part of the index, and the directory can be
  shown as ignored.

  - When core.ignorecase is true on the other hand, directories are
  reported as part of the index, and the directory is dropped, thus not
  displayed as ignored.

 Fix that behavior by allowing indexed file to be added when looking for
 ignored files.

  - Ignored tracked and untracked directories are treated the same way
  when looking for ignored files, so we should not care about their index
  status.
  - Files are dismissed by treat_file() if they belong to the
  index, so that step would have been a no-op anyway.

Here is my attempt...

When enumerating paths that are ignored, paths the index knows
about are not included in the result.  The index knows about
check is done by consulting the name hash, not the actual
contents of the index:

 - When core.ignorecase is false, directory names are not in the
   name hash, and ignored ones are shown as ignored (directories
   can never be tracked anyway).

 - When core.ignorecase is true, however, the name hash keeps
   track of the names of directories, in order to detect
   additions of the paths under different cases.  This causes
   ignored directories to be mistakenly excluded when
   enumerating ignored paths.

Stop excluding directories that are in the name hash when
looking for ignored files in dir_add_name(); the names that are
actually in the index are excluded much earlier in the callchain
in treat_file(), so this fix will not make them mistakenly
identified as ignored.

Signed-off-by: Antoine Pelisse apeli...@gmail.com
Reviewed-by: Jeff King p...@peff.net
Signed-off-by: Junio C Hamano gits...@pobox.com

diff --git a/dir.c b/dir.c
index 9b80348..f836590 100644
--- a/dir.c
+++ b/dir.c
@@ -672,7 +672,8 @@ static struct dir_entry *dir_entry_new(const char 
*pathname, int len)
 
 static struct dir_entry *dir_add_name(struct dir_struct *dir, const char 
*pathname, int len)
 {
-   if (cache_name_exists(pathname, len, ignore_case))
+   if (!(dir-flags  DIR_SHOW_IGNORED) 
+   cache_name_exists(pathname, len, ignore_case))
return NULL;
 
ALLOC_GROW(dir-entries, dir-nr+1, dir-alloc);
@@ -877,11 +878,7 @@ static int treat_file(struct dir_struct *dir, struct 
strbuf *path, int exclude,
if (exclude)
exclude_file = !(dir-flags  DIR_SHOW_IGNORED);
else if (dir-flags  DIR_SHOW_IGNORED) {
-   /*
-* Optimization:
-* Don't spend time on indexed files, they won't be
-* added to the list anyway
-*/
+   /* Always exclude indexed files */
struct cache_entry *ce = index_name_exists(the_index,
path-buf, path-len, ignore_case);
 
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2] status: always report ignored tracked directories

2013-01-07 Thread Antoine Pelisse
 Here is my attempt...

 When enumerating paths that are ignored, paths the index knows
 about are not included in the result.  The index knows about
 check is done by consulting the name hash, not the actual
 contents of the index:

  - When core.ignorecase is false, directory names are not in the
name hash, and ignored ones are shown as ignored (directories
can never be tracked anyway).

  - When core.ignorecase is true, however, the name hash keeps
track of the names of directories, in order to detect
additions of the paths under different cases.  This causes
ignored directories to be mistakenly excluded when
enumerating ignored paths.

 Stop excluding directories that are in the name hash when
 looking for ignored files in dir_add_name(); the names that are
 actually in the index are excluded much earlier in the callchain
 in treat_file(), so this fix will not make them mistakenly
 identified as ignored.

 Signed-off-by: Antoine Pelisse apeli...@gmail.com
 Reviewed-by: Jeff King p...@peff.net
 Signed-off-by: Junio C Hamano gits...@pobox.com

I like it a lot, thanks to both of you
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] status: always report ignored tracked directories

2013-01-06 Thread Antoine Pelisse
Tracked directories (i.e. directories containing tracked files) that
are ignored must be reported as ignored if they contain untracked files.

Currently, files in the index can't be reported as ignored and are
automatically dropped from the list:

 - When core.ignorecase is false, directories (which are not directly
 tracked) are not listed as part of the index, and the directory can be
 shown as ignored.

 - When core.ignorecase is true on the other hand, directories are
 reported as part of the index, and the directory is dropped, thus not
 displayed as ignored.

Fix that behavior by allowing indexed file to be added when looking for
ignored files.

 - Ignored tracked and untracked directories are treated the same way
 when looking for ignored files, so we should not care about their index
 status.
 - Files are dismissed by treat_file() if they belong to the
 index, so that step would have been a no-op anyway.

Signed-off-by: Antoine Pelisse apeli...@gmail.com
---
 dir.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/dir.c b/dir.c
index 9b80348..f836590 100644
--- a/dir.c
+++ b/dir.c
@@ -672,7 +672,8 @@ static struct dir_entry *dir_entry_new(const char 
*pathname, int len)

 static struct dir_entry *dir_add_name(struct dir_struct *dir, const char 
*pathname, int len)
 {
-   if (cache_name_exists(pathname, len, ignore_case))
+   if (!(dir-flags  DIR_SHOW_IGNORED) 
+   cache_name_exists(pathname, len, ignore_case))
return NULL;

ALLOC_GROW(dir-entries, dir-nr+1, dir-alloc);
@@ -877,11 +878,7 @@ static int treat_file(struct dir_struct *dir, struct 
strbuf *path, int exclude,
if (exclude)
exclude_file = !(dir-flags  DIR_SHOW_IGNORED);
else if (dir-flags  DIR_SHOW_IGNORED) {
-   /*
-* Optimization:
-* Don't spend time on indexed files, they won't be
-* added to the list anyway
-*/
+   /* Always exclude indexed files */
struct cache_entry *ce = index_name_exists(the_index,
path-buf, path-len, ignore_case);

--
1.7.12.4.3.g90f5e2d

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html