* Q: Ignore ./foo, but not script/foo
@ 2018-07-19 7:38 Ulrich Windl
2018-07-19 8:01 ` 3Ævar Arnfjörð Bjarmason
[not found] ` <CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: Ulrich Windl @ 2018-07-19 7:38 UTC (permalink / raw)
To: git
Hi!
I have a (simple) question I could not answer elegantly from the gitignore(5) manual page:
A project produces a "foo" binary in the root directory that I want to ignore (So I put "foo" into .gitignore)
Unfortunately I found out taht I cannot have a "script/foo" added while "foo" is in .gitignore.
So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", but now "foo" is not ignored any more!
Is there as solution other than:?
--
foo
!script/foo
!bla/foo
#etc.
--
If "foo" is one exception to generally using foo elsewhere, it seems to be counterproductive to have to add exceptions for all the cases that are not exceptions, while "foo" is the only exception...
Did I miss something? If so, maybe add it to a future manual page.
Regards,
Ulrich
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Q: Ignore ./foo, but not script/foo
2018-07-19 7:38 Q: Ignore ./foo, but not script/foo Ulrich Windl
@ 2018-07-19 8:01 ` 3Ævar Arnfjörð Bjarmason
2018-07-19 9:06 ` Timothy Rice
[not found] ` <CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: 3Ævar Arnfjörð Bjarmason @ 2018-07-19 8:01 UTC (permalink / raw)
To: Ulrich Windl; +Cc: git
On Thu, Jul 19 2018, Ulrich Windl wrote:
> Hi!
>
> I have a (simple) question I could not answer elegantly from the gitignore(5) manual page:
>
> A project produces a "foo" binary in the root directory that I want to ignore (So I put "foo" into .gitignore)
> Unfortunately I found out taht I cannot have a "script/foo" added while "foo" is in .gitignore.
> So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo", but now "foo" is not ignored any more!
>
> Is there as solution other than:?
> --
> foo
> !script/foo
> !bla/foo
> #etc.
The solution is to just do:
echo /foo >.gitignore
Then it'll ignore the top-level /foo, but nothing else. How did you come
up with this "./" syntax? It's not understood by gitignore. From
gitignore(5):
A leading slash matches the beginning of the pathname. For example,
"/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Q: Ignore ./foo, but not script/foo
2018-07-19 8:01 ` 3Ævar Arnfjörð Bjarmason
@ 2018-07-19 9:06 ` Timothy Rice
2018-07-19 9:22 ` Konstantin Khomoutov
2018-07-19 9:30 ` Ævar Arnfjörð Bjarmason
0 siblings, 2 replies; 6+ messages in thread
From: Timothy Rice @ 2018-07-19 9:06 UTC (permalink / raw)
To: 3Ævar Arnfjörð Bjarmason; +Cc: Ulrich Windl, git
> How did you come up with this "./" syntax?
It is a Unix thing: "./" or just "." refers to the current directory.
When calling scripts or programs in the current directory from a Unix
command line, it is required to refer to them as, say, "./foo" (not just
"foo") -- unless "." is in your PATH.
Most people do put "." in their PATH for convenience but it is considered a
little unsafe [1].
Personally, I am surprised that gitignore does not understand this
notation. To me, OPs meaning was crystal clear: "./foo" should mean to only
ignore the foo in the repository's root directory.
[1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default
~ Tim
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Q: Ignore ./foo, but not script/foo
2018-07-19 9:06 ` Timothy Rice
@ 2018-07-19 9:22 ` Konstantin Khomoutov
2018-07-19 9:30 ` Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 6+ messages in thread
From: Konstantin Khomoutov @ 2018-07-19 9:22 UTC (permalink / raw)
To: Timothy Rice; +Cc: 3Ævar Arnfjörð Bjarmason, Ulrich Windl, git
On Thu, Jul 19, 2018 at 07:06:57PM +1000, Timothy Rice wrote:
[...]
> Most people do put "." in their PATH for convenience
[...]
IMO this is a gross overstatement: personally, I know of no person using
a Unix-like operation system who does this.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Q: Ignore ./foo, but not script/foo
2018-07-19 9:06 ` Timothy Rice
2018-07-19 9:22 ` Konstantin Khomoutov
@ 2018-07-19 9:30 ` Ævar Arnfjörð Bjarmason
1 sibling, 0 replies; 6+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2018-07-19 9:30 UTC (permalink / raw)
To: Timothy Rice; +Cc: Ulrich Windl, git
On Thu, Jul 19 2018, Timothy Rice wrote:
>> How did you come up with this "./" syntax?
>
> It is a Unix thing: "./" or just "." refers to the current directory.
>
> When calling scripts or programs in the current directory from a Unix
> command line, it is required to refer to them as, say, "./foo" (not just
> "foo") -- unless "." is in your PATH.
>
> Most people do put "." in their PATH for convenience but it is considered a
> little unsafe [1].
>
> Personally, I am surprised that gitignore does not understand this
> notation. To me, OPs meaning was crystal clear: "./foo" should mean to only
> ignore the foo in the repository's root directory.
>
> [1] https://superuser.com/questions/156582/why-is-not-in-the-path-by-default
To clarify I was trying to fish for whether we'd accidentally documented
"./" somewhere since OP was making references to the docs.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Antw: Re: Q: Ignore ./foo, but not script/foo
[not found] ` <CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>
@ 2018-07-19 11:00 ` Ulrich Windl
0 siblings, 0 replies; 6+ messages in thread
From: Ulrich Windl @ 2018-07-19 11:00 UTC (permalink / raw)
To: Sebastian Staudt; +Cc: git
>>> Sebastian Staudt <koraktor@gmail.com> schrieb am 19.07.2018 um 09:55 in
Nachricht
<CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>:
> Hello Ulrich,
>
> if you want to ignore a file in the root of the repository (and only
> there) this is the correct syntax:
>
> /foo
Hi!
Thanks, you are perfectly right: It works, and actually, when read carefully enough, the last item in "PATTERN FORMAT" explains that.
Maybe the EXAMPLES could have an example for each item (5 cases) described ;-)
Regards,
Ulrich
>
> Best regards,
> Sebastian
> Am Do., 19. Juli 2018 um 09:45 Uhr schrieb Ulrich Windl
> <Ulrich.Windl@rz.uni-regensburg.de>:
>>
>> Hi!
>>
>> I have a (simple) question I could not answer elegantly from the
> gitignore(5) manual page:
>>
>> A project produces a "foo" binary in the root directory that I want to
> ignore (So I put "foo" into .gitignore)
>> Unfortunately I found out taht I cannot have a "script/foo" added while
> "foo" is in .gitignore.
>> So I changed "foo" to "./foo" in .gitignore. I can could add "script/foo",
> but now "foo" is not ignored any more!
>>
>> Is there as solution other than:?
>> --
>> foo
>> !script/foo
>> !bla/foo
>> #etc.
>> --
>>
>> If "foo" is one exception to generally using foo elsewhere, it seems to be
> counterproductive to have to add exceptions for all the cases that are not
> exceptions, while "foo" is the only exception...
>>
>> Did I miss something? If so, maybe add it to a future manual page.
>>
>> Regards,
>> Ulrich
>>
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-07-19 11:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 7:38 Q: Ignore ./foo, but not script/foo Ulrich Windl
2018-07-19 8:01 ` 3Ævar Arnfjörð Bjarmason
2018-07-19 9:06 ` Timothy Rice
2018-07-19 9:22 ` Konstantin Khomoutov
2018-07-19 9:30 ` Ævar Arnfjörð Bjarmason
[not found] ` <CA+xP2SZJ0VN0Y7SChAx1a8joVMKMU2R9d0je801i=9SuLicF3w@mail.gmail.com>
2018-07-19 11:00 ` Antw: " Ulrich Windl
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).