git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Danial Alihosseini <danial.alihosseini@gmail.com>
To: philipoakley@iee.email
Cc: Junio C Hamano <gitster@pobox.com>,
	Chris Torek <chris.torek@gmail.com>,
	Derrick Stolee <stolee@gmail.com>, Johannes Sixt <j6t@kdbg.org>,
	Jeff King <peff@peff.net>, Derrick Stolee <dstolee@microsoft.com>,
	Git List <git@vger.kernel.org>
Subject: Re: git 2.34.0: Behavior of `**` in gitignore is different from previous versions.
Date: Wed, 24 Nov 2021 00:43:29 +0330	[thread overview]
Message-ID: <CACLOEFYoqDsAhhHEMGXvtrkJLSpKdj8Rp1WtoBrPtJZbZN-s7Q@mail.gmail.com> (raw)
In-Reply-To: <09cbc27d-8fdf-ed84-716f-23fd8dbb11de@iee.email>

>  * Git opens and reads the working tree directory.  For each file
>
>    or directory that is actually present here, Git checks it
>
>    against the ignore rules.  Some rules match only directories
>
>    and others match both directories and files.  Some rules say
>    "do ignore" and some say "do not ignore".
>  * The *last* applicable rule wins.
>  * If this is a file and the file is ignored, it's ignored.
>    Unless, that is, it's in the index already, because then it's
>    tracked and can't be ignored.
>  * If this is a directory and the directory is ignored, it's
>    not even opened and read.  It's not in the index because
>    directories are never in the index (at least nominally).
>    If it is opened and read, the entire set of rules here
>    apply recursively.

> I do think it would be sensible for Git to read a `.gitignore`
>
> that says:
>
>     *
>
>     !a/b/c
>
> as meaning:
>     *
>     !a/
>     !a/b/
>     !a/b/c
> That is, declaring an un-ignored file within some ignored
> directory should automatically imply that we *must* un-ignore the
> parents.

Thanks, Chris. Yes, it mostly makes sense to me too.
I think this will better describe the gitignore behavior.
However, checking the indexed files at first may enhance it.

In addition to that, there should be an exception about negating patterns.
For example, for the "!**/file.txt" pattern, it might be tricky to
re-include all possible parents of "file.txt" files. You have to
traverse directories to reach files and find out which parents to
un-ignore. Any negating pattern with "**" at the beginning or in the
middle of the pattern can make trouble.
The existing rule which states the file cannot be re-included in case
of ignored parents may help to prevent this.

Thanks
Danial

      reply	other threads:[~2021-11-23 21:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-18 16:41 git 2.34.0: Behavior of `**` in gitignore is different from previous versions Danial Alihosseini
2021-11-18 17:04 ` Jeff King
2021-11-18 22:09   ` Derrick Stolee
2021-11-19  4:01     ` Danial Alihosseini
2021-11-19 14:51       ` Derrick Stolee
2021-11-19 17:06         ` Danial Alihosseini
2021-11-19 20:05         ` Johannes Sixt
2021-11-19 20:33           ` Derrick Stolee
2021-11-19 20:57             ` Ævar Arnfjörð Bjarmason
2021-11-20 22:41             ` Chris Torek
2021-11-21  0:46               ` Junio C Hamano
2021-11-23 12:21                 ` Philip Oakley
2021-11-23 21:13                   ` Danial Alihosseini [this message]

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=CACLOEFYoqDsAhhHEMGXvtrkJLSpKdj8Rp1WtoBrPtJZbZN-s7Q@mail.gmail.com \
    --to=danial.alihosseini@gmail.com \
    --cc=chris.torek@gmail.com \
    --cc=dstolee@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=peff@peff.net \
    --cc=philipoakley@iee.email \
    --cc=stolee@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).