public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Stefan Beller <stefanbeller@gmail•com>
Cc: "\/#!\/JoePea" <trusktr@gmail•com>,
	Git Mailing List <git@vger•kernel.org>
Subject: Re: Relative paths don't work in .gitignore as would be expected.
Date: Tue, 03 Feb 2015 12:11:37 -0800	[thread overview]
Message-ID: <xmqqtwz2rc06.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CALbm-Ea7X3dDrMUw0sDhWf0sg+zs7oRUkRD+aPzD9fHqB=ZuWQ@mail.gmail.com> (Stefan Beller's message of "Mon, 2 Feb 2015 18:18:27 -0800")

Stefan Beller <stefanbeller@gmail•com> writes:

> 2015-02-02 11:15 GMT-08:00 Junio C Hamano <gitster@pobox•com>:
>
>> Isn't gitignore(5) documentation reasonably clear?
>> ...
>>  - A leading slash matches the beginning of the pathname. For
>>    example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
>>
>>> That's true, though you'd never (barely?) git version control an entire
>>> file system?
>>
>> When you have the entire file system under /.git, "/var/" still
>> would be the right way to spell a pattern to match ...
>> ... and lives in the root level of the filesystem (because of the
>> leading '/' anchors
>> the pattern to the same level as the file the pattern appears in,
>> i.e. /.gitignore) and no other place.
>
> ... Now I realize git treats the repository
> root literally as the root and hence absolute paths starting with "/"
> make totally sense inside git as the world stops for git outside its
> work directory.

Only when the pattern appears in .gitignore at the top-level of the
project, you can say: "/*.js" matches files with ".js" suffix at the
root level of the project because '/' means 'root'.

But that explanation breaks down for "t/.gitignore" that has entries
like "/.prove".  It is not excluding ".prove" at the top-level of
the project.  It is excluding those that appear at the same level as
that ignore file in question lives in, i.e. the "t/" directory.  It
excludes "t/.prove", it excludes neither ".prove" at the top-level
nor "t/tt/ttt/.prove".

In hindsight, using '/' prefix as a way to anchor the patter to the
same directory the .gitignore file appears in was suboptimal,
exactly because it would invite the above reaction.  But I do not
know if using "./" as the prefix to denote the same thing would have
been better.

  reply	other threads:[~2015-02-03 20:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-01 22:51 Relative paths don't work in .gitignore as would be expected /#!/JoePea
2015-02-02  5:57 ` Stefan Beller
2015-02-02 19:15   ` Junio C Hamano
2015-02-03  2:18     ` Stefan Beller
2015-02-03 20:11       ` Junio C Hamano [this message]
     [not found] <CAKU1PAXgofoOqtFMrLYyRoFqNp3Poj-PO35eh1ukxR=h29FPfQ@mail.gmail.com>
2015-02-12  6:28 ` /#!/JoePea

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=xmqqtwz2rc06.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=stefanbeller@gmail$(echo .)com \
    --cc=trusktr@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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