* Gitignore documentation
@ 2019-01-12 20:16 Maris Razvan
2019-01-14 18:47 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Maris Razvan @ 2019-01-12 20:16 UTC (permalink / raw)
To: git
Hello,
I was reading the gitignore documentation
(https://git-scm.com/docs/gitignore), especially the following
paragraph:
"If the pattern does not contain a slash /, Git treats it as
a shell glob pattern and checks for a match against the pathname
relative to the location of the .gitignore file (relative to the
toplevel of the work tree if not from a .gitignore file)."
From that paragraph I understand that if I have the following
directory structure:
.gitignore
a
f
(the root of the repository contains the file .gitignore and the
folder a, while the file f is inside folder a)
where the file .gitignore contains only the pattern f, when file "f"
is tested whether it should be ignored or not, the pattern f in
.gitignore is matched against the "pathname relative to the location
of the .gitignore file" (which is a/f). Because "f" (the pattern) does
not match "a/f" (the pathname relative to the location of .gitignore),
the file "f" should not be ignored. However, if I test this scenario,
git ignores the file (this behaviour is consistent with the examples
from the rest of the documentation and other explanations on the
internet).
I looked at the history of the "Documentation/gitignore.txt" file on
the github repository and I saw that initially the paragraph looked
like this:
"If the pattern does not contain a slash '/', git treats it as
a shell glob pattern and checks for a match against the pathname
without leading directories."
This old version of the paragraph is consistent with git's current behaviour.
Then I saw the following commit
https://github.com/git/git/commit/81c13fde379c46cad6b6e4a03ed7ee4f686c030f#diff-7fea460d44f92f185e7add8aa5620305,
which changed that paragraph to the current version.
However, I cannot see how the two wordings (the original one and the
current one) are the same.
I would really appreciate if someone could explain how to read the
current version of the paragraph such that it is consistent with git's
behaviour.
Thank you,
Razvan Maris
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Gitignore documentation
2019-01-12 20:16 Gitignore documentation Maris Razvan
@ 2019-01-14 18:47 ` Junio C Hamano
2019-01-14 21:38 ` Jonathan Nieder
0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2019-01-14 18:47 UTC (permalink / raw)
To: Maris Razvan; +Cc: git, Jonathan Nieder
Maris Razvan <razvan.alex.maris@gmail.com> writes:
> I was reading the gitignore documentation
> (https://git-scm.com/docs/gitignore), especially the following
> paragraph:
>
> "If the pattern does not contain a slash /, Git treats it as
> a shell glob pattern and checks for a match against the pathname
> relative to the location of the .gitignore file (relative to the
> toplevel of the work tree if not from a .gitignore file)."
>
> From that paragraph I understand that if I have the following
> directory structure:
>
> .gitignore
> a
> f
>
> (the root of the repository contains the file .gitignore and the
> folder a, while the file f is inside folder a)
> where the file .gitignore contains only the pattern f, when file "f"
> is tested whether it should be ignored or not, the pattern f in
> .gitignore is matched against the "pathname relative to the location
> of the .gitignore file" (which is a/f). Because "f" (the pattern) does
> not match "a/f" (the pathname relative to the location of .gitignore),
> the file "f" should not be ignored. However, if I test this scenario,
> git ignores the file (this behaviour is consistent with the examples
> from the rest of the documentation and other explanations on the
> internet).
>
> I looked at the history of the "Documentation/gitignore.txt" file on
> the github repository and I saw that initially the paragraph looked
> like this:
>
> "If the pattern does not contain a slash '/', git treats it as
> a shell glob pattern and checks for a match against the pathname
> without leading directories."
>
> This old version of the paragraph is consistent with git's current behaviour.
>
> Then I saw the following commit
> https://github.com/git/git/commit/81c13fde379c46cad6b6e4a03ed7ee4f686c030f#diff-7fea460d44f92f185e7add8aa5620305,
> which changed that paragraph to the current version.
> However, I cannot see how the two wordings (the original one and the
> current one) are the same.
Thanks.
Jonathan, after re-reading 81c13fde ("gitignore.5: Clarify matching
rules", 2010-03-05), I do not recall why we thought this part of the
change was a good idea, either. Patterns with slash is anchored at
one directory, and that directory is the one that has per-directory
.gitignore file. Patterns without slash (including a pattern that
ends with but otherwise has no other slash) are supposed to match at
every level below the directory that the pattern is defined in.
Documentation/gitignore.txt | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 1c94f08ff4..bf1182169e 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -98,9 +98,7 @@ PATTERN FORMAT
- If the pattern does not contain a slash '/', Git treats it as
a shell glob pattern and checks for a match against the
- pathname relative to the location of the `.gitignore` file
- (relative to the toplevel of the work tree if not from a
- `.gitignore` file).
+ pathname without leading directories.
- Otherwise, Git treats the pattern as a shell glob: "`*`" matches
anything except "`/`", "`?`" matches any one character except "`/`"
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: Gitignore documentation
2019-01-14 18:47 ` Junio C Hamano
@ 2019-01-14 21:38 ` Jonathan Nieder
2019-01-14 21:52 ` Junio C Hamano
2019-01-15 9:27 ` Duy Nguyen
0 siblings, 2 replies; 5+ messages in thread
From: Jonathan Nieder @ 2019-01-14 21:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Maris Razvan, git, Nguyễn Thái Ngọc Duy
Hi,
Junio C Hamano wrote:
> Patterns with slash is anchored at
> one directory, and that directory is the one that has per-directory
> .gitignore file. Patterns without slash (including a pattern that
> ends with but otherwise has no other slash) are supposed to match at
> every level below the directory that the pattern is defined in.
I had a sense of deja vu, and found
https://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/
Any idea what happened there? Would it be useful for me to rebase
and revive that series?
Thanks,
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Gitignore documentation
2019-01-14 21:38 ` Jonathan Nieder
@ 2019-01-14 21:52 ` Junio C Hamano
2019-01-15 9:27 ` Duy Nguyen
1 sibling, 0 replies; 5+ messages in thread
From: Junio C Hamano @ 2019-01-14 21:52 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Maris Razvan, git, Nguyễn Thái Ngọc Duy
Jonathan Nieder <jrnieder@gmail.com> writes:
> https://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/
>
> Any idea what happened there? Would it be useful for me to rebase
> and revive that series?
No idea what happend there.
Anyway, I quickly read them over and found nothing questionable,
except perhaps the moving of "slash is dropped for the purpose of
the remaining rules" in 1/4 were probably not a great idea (IOW, I
found that it leaves a stronger impression to the readers to say it
upfront in the paragraph), but I do not think it is a show-stopper.
Reviving the topic would indeed be a good idea.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Gitignore documentation
2019-01-14 21:38 ` Jonathan Nieder
2019-01-14 21:52 ` Junio C Hamano
@ 2019-01-15 9:27 ` Duy Nguyen
1 sibling, 0 replies; 5+ messages in thread
From: Duy Nguyen @ 2019-01-15 9:27 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Junio C Hamano, Maris Razvan, Git Mailing List
On Tue, Jan 15, 2019 at 4:38 AM Jonathan Nieder <jrnieder@gmail.com> wrote:
>
> Hi,
>
> Junio C Hamano wrote:
>
> > Patterns with slash is anchored at
> > one directory, and that directory is the one that has per-directory
> > .gitignore file. Patterns without slash (including a pattern that
> > ends with but otherwise has no other slash) are supposed to match at
> > every level below the directory that the pattern is defined in.
>
> I had a sense of deja vu, and found
> https://public-inbox.org/git/20111107080926.GC30486@elie.hsd1.il.comcast.net/
>
> Any idea what happened there? Would it be useful for me to rebase
> and revive that series?
I don't remember what happened either. But yeah it's always good to
improve this text.
--
Duy
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-15 9:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-12 20:16 Gitignore documentation Maris Razvan
2019-01-14 18:47 ` Junio C Hamano
2019-01-14 21:38 ` Jonathan Nieder
2019-01-14 21:52 ` Junio C Hamano
2019-01-15 9:27 ` Duy Nguyen
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).