Re: .gitignore sub-dir exclusions not overriding '*'

2014-11-19 Thread Duy Nguyen
On Wed, Nov 19, 2014 at 10:40 AM, Phil Pennock
phil-gi...@phil.spodhuis.org wrote:
 Expected to work as .gitignore in top-level of repo:

 *
 !**/*.asc
 !.gitignore


gitignore man page has this It is not possible to re-include a file
if a parent directory of that file is excluded. In this case,
directory foo is ignored by *. Although it makes sense for this
particular case to re-include something in foo because we can clearly
see there are rules to re-include. It's on my todo list, but I don't
know when it will be implemented.
-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: .gitignore sub-dir exclusions not overriding '*'

2014-11-19 Thread Phil Pennock
On 2014-11-19 at 16:48 +0700, Duy Nguyen wrote:
 On Wed, Nov 19, 2014 at 10:40 AM, Phil Pennock
 phil-gi...@phil.spodhuis.org wrote:
  Expected to work as .gitignore in top-level of repo:
 
  *
  !**/*.asc
  !.gitignore
 
 
 gitignore man page has this It is not possible to re-include a file
 if a parent directory of that file is excluded. In this case,
 directory foo is ignored by *. Although it makes sense for this
 particular case to re-include something in foo because we can clearly
 see there are rules to re-include. It's on my todo list, but I don't
 know when it will be implemented.

Thanks for this and the patches and discussion which follow.

I didn't cover it in my report, but one of the scenarios I tried was to
explicitly re-include directories, to make them candidates again, and
either use directory-matching patterns in the top-level .gitignore or to
use per-directory .gitignore to handle those directories.

Looking fresh today, I see that I failed to compare baseline behaviour
without a .gitignore when using `git status` as a baseline for
comparison.  So a .gitignore like this:

*
!*/
!*.asc

appeared to not work; even within the `foo/` sub-directory, `git status`
shows no candidates for inclusion.  But this is true even without a
.gitignore.  *sigh*

In fact, it looks like the simple three lines above work, without any
.gitignore in sub-directories.

The behaviour which confused me between this simplified test-case and
the original was that `git status` shows files in the top-level
directory which are untracked, and in untracked files sub-directories
where some other file in that directory is already tracked, but if no
file in the sub-directory is already tracked, then `git status` does not
report the files for inclusion, even if the cwd is inside that
directory.

I tied myself in knots trying to avoid adding unencrypted files to the
repo.

Thanks,
-Phil
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: .gitignore sub-dir exclusions not overriding '*'

2014-11-19 Thread Duy Nguyen
On Thu, Nov 20, 2014 at 6:41 AM, Phil Pennock
phil-gi...@phil.spodhuis.org wrote:
 On 2014-11-19 at 16:48 +0700, Duy Nguyen wrote:
 On Wed, Nov 19, 2014 at 10:40 AM, Phil Pennock
 phil-gi...@phil.spodhuis.org wrote:
  Expected to work as .gitignore in top-level of repo:
 
  *
  !**/*.asc
  !.gitignore
 

 gitignore man page has this It is not possible to re-include a file
 if a parent directory of that file is excluded. In this case,
 directory foo is ignored by *. Although it makes sense for this
 particular case to re-include something in foo because we can clearly
 see there are rules to re-include. It's on my todo list, but I don't
 know when it will be implemented.

 Thanks for this and the patches and discussion which follow.

 I didn't cover it in my report, but one of the scenarios I tried was to
 explicitly re-include directories, to make them candidates again, and
 either use directory-matching patterns in the top-level .gitignore or to
 use per-directory .gitignore to handle those directories.

 Looking fresh today, I see that I failed to compare baseline behaviour
 without a .gitignore when using `git status` as a baseline for
 comparison.  So a .gitignore like this:

 *
 !*/
 !*.asc

 appeared to not work; even within the `foo/` sub-directory, `git status`
 shows no candidates for inclusion.  But this is true even without a
 .gitignore.  *sigh*

I should have read this mail before replying to Junio in the other
email :( Yeah the !*/ would re-include dirs back. I'm not sure if
there are any side effects by doing this, no time to think about this
yet. Maybe we can put this in the example section in gitignore man
page with more explanation.

 In fact, it looks like the simple three lines above work, without any
 .gitignore in sub-directories.

 The behaviour which confused me between this simplified test-case and
 the original was that `git status` shows files in the top-level
 directory which are untracked, and in untracked files sub-directories
 where some other file in that directory is already tracked, but if no
 file in the sub-directory is already tracked, then `git status` does not
 report the files for inclusion, even if the cwd is inside that
 directory.

 I tied myself in knots trying to avoid adding unencrypted files to the
 repo.

 Thanks,
 -Phil



-- 
Duy
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


.gitignore sub-dir exclusions not overriding '*'

2014-11-18 Thread Phil Pennock
The behaviour below is seen with both git 1.8.3.2 and git 2.1.3; I am
not subscribed to the vger list, please keep me in the CC list.

Use-case: git repo which only holds PGP-encrypted files with a .asc
extension, no matter which sub-directory they're in, or if in the top
directory.

Simple layout; for demo purposes names starting 'incl' should end up
included, those starting 'excl' should end up excluded, but not based on
those prefices: they're success result indicators; so:

cd wherever
git init
mkdir foo
touch incl.asc excl excl.txt foo/incl.asc foo/excl.txt foo/excl
$EDITOR .gitignore

Expected to work as .gitignore in top-level of repo:

*
!**/*.asc
!.gitignore

With that, `git status` ignores the contents of foo/ thusly:

$ git check-ignore -v foo/incl.asc
.gitignore:1:*  foo/incl.asc

Commenting out the '*' line and removing the '!' from the second, the
**/*.asc clearly matches.  The only way I can make this style work is to
set the first line to '**/*.*' which fails to exclude the plain 'excl'
files (no extension).

It seems that there's some magic around '*' as the entire final path
component of a pattern which causes it to match against the entire
directory, and excludes of the directory can not be overriden by matches
against '*.ext' within the directory, even when they come later in the
same config file at the same precedence.

This does not seem to my reading to match the behaviour described by
`git help gitignore` (checked in both versions of git) and so seems to
me to be a bug, but if it's a failure of my understanding, please help
me to understand where I messed up.

Thanks,
-Phil
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html