Re: [PATCH] Documentation: enhance gitignore whitelist example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 04/05/2011 03:15 PM, Johannes Sixt wrote:
>>> @@ -87,7 +89,8 @@ PATTERN FORMAT
>>>
>>>   - Otherwise, git treats the pattern as a shell glob suitable
>>>     for consumption by fnmatch(3) with the FNM_PATHNAME flag:
>>> -   wildcards in the pattern will not match a / in the pathname.
>>> +   wildcards in the pattern will not match a / in the pathname,
>>> +   and do not ignore files with a leading . in the pathname.
> 
> I don't think this is correct. * matches .gitignore. I tried it.

That was my point.  * _does_ match .gitignore, even though for normal
shell globs, FNM_PERIOD is set and * does not match .gitignore.  That
is, while in the shell 'dir/*' only matches non-dot files, in .gitignore
it matches all files including dot-files.

Any ideas for a better way to word that?

> I propose a paragraph like this in the NOTES section:
> 
> --- 8< ---
> When a directory is ignored, it is not possible to un-ignore a single file 
> somewhere in the directory using another pattern. E.g., with the patterns
> 
> --------------
> /build/
> !/build/tests/results
> --------------
> 
> the file "build/tests/results" is still ignored because when a directory is 
> ignored, its contents are never investigated. In a situation where a few 
> exceptions in an otherwise ignored hierarchy are needed, the recommended 
> procedure is to specify to ignore the root of the hierarchy and then to 'git 
> add -f' the exceptional files. Subsequent changes to the files will not be 
> ignored.

Yeah, but then you have to 'git add -f path/to/file' them every time you
change them, or use the sledgehammer of 'git add .'.

Does it make any better sense to document:

  /build/*
  !/build/*/
  /build/*/*
  !/build/foo/baz

which ignores all files in build, then un-ignores directories, then
ignores all files in subdirectories of build except for the desired
multi-level file under build?  At which point you no longer need 'git
add -f', but can simply do 'git add build' to pick up /build/foo/baz in
one go without warning?

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]