git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: shunichi fuji <palglowr@gmail.com>,
	Pierre Habouzit <madcoder@debian.org>,
	Andreas Ericsson <ae@op5.se>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Unify the use of standard set of exclude files
Date: Wed, 14 Nov 2007 23:41:02 -0800	[thread overview]
Message-ID: <7vk5ok6jn5.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7v4pfo813i.fsf_-_@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Wed, 14 Nov 2007 22:38:41 -0800")

By the way, I think the way in which excluded() is called inside
ls-files for --cached, --staged, --deleted and --modified is
totally bogus, and as a result, ls-files does not honor
per-directory exclude files properly.

This is because dir.c:excluded() needs to be called after
setting up the exclude_list stack properly, just like how
dir.c:read_directory() and unpack-trees.c:unpack_trees_rec()
do.  The directory traversal should look like this:

 - Call push_exclude_per_directory() upon entering a directory.
   This reads the per directory exclude file (.gitignore) from
   the directory, and push it into the existing stack.  This
   way, the patterns from the file is set up to override the
   existing patterns from the .gitignore files of higher level
   directories.

 - Ask excluded() if your paths in that directory matches, and
   do whatever you want to happen.

 - Call pop_exclude_per_directory() when leaving the directory,
   to free the patterns read from the .gitignore file there.

Because the codepaths in question just iterate over the cache
entries without telling the per-directory exclude file stack
which set of .gitignore files should apply to the inquiry using
push/pop mechanism, I _think_ excluded(dir, "a/b") calls in the
codepaths do not honor .gitignore nor a/.gitignore file when
checking if "a/b" is to be ignored.

The push/pop mechanism was designed to be used in read_directory()
and it was a good match to the code structure to make recursive
calls to read_directory_recursive().  Because the paths are
sorted in the pathname order, we can make appropriate calls to
push/pop while iterating over the cache in these codepaths to
fix this issue.

As a longer term fix, I think it makes more sense to make
excluded() automatically push/pop the per directory exclude file
stack, just like the gitattributes mechanism maintains the
attribute stack to match and cache the last checked path.

  parent reply	other threads:[~2007-11-15  7:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-13 21:49 git-clean won't read global ignore shunichi fuji
2007-11-13 22:50 ` Pierre Habouzit
2007-11-14  8:05   ` Junio C Hamano
2007-11-14  8:42     ` Andreas Ericsson
2007-11-14  9:03       ` Junio C Hamano
2007-11-14 17:46     ` Johannes Schindelin
2007-11-15  4:21     ` Miles Bader
2007-11-15  4:33       ` Miles Bader
2007-11-15  6:38     ` [PATCH] Unify the use of standard set of exclude files Junio C Hamano
2007-11-15  7:04       ` Jeff King
2007-11-15  9:03         ` Junio C Hamano
2007-11-15  9:15           ` Jeff King
2007-11-15  7:41       ` Junio C Hamano [this message]
2007-11-15 10:07     ` git-clean won't read global ignore Matthieu Moy
2007-11-15 17:27       ` Junio C Hamano
2007-11-15 17:50         ` Matthieu Moy

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=7vk5ok6jn5.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=ae@op5.se \
    --cc=git@vger.kernel.org \
    --cc=madcoder@debian.org \
    --cc=palglowr@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).