Bazaar Version Control System

Comment 1 for bug 57637

John A Meinel (jameinel) wrote :

The bug doesn't seem related to dotfiles specifically. I was able to reproduce the problem as:

$ bzr ignore './f*'
$ mkdir foo
$ touch foo/bar
$ bzr add foo
added foo
ignored 1 file(s).
If you wish to add some of these files, please add them by name.

Also, this test fails:
=== modified file 'bzrlib/tests/workingtree_implementations/test_is_ignored.py'
--- bzrlib/tests/workingtree_implementations/test_is_ignored.py 2006-07-21 04:02:14 +0000
+++ bzrlib/tests/workingtree_implementations/test_is_ignored.py 2006-08-25 01:16:27 +0000
@@ -77,6 +77,13 @@
         self.assertEqual(None, tree.is_ignored(' xx'))
         self.assertEqual(None, tree.is_ignored('subdir/xx '))

+ def test_dotfile(self):
+ tree = self.make_branch_and_tree('tree')
+ self.build_tree_contents([('tree/.bzrignore', './f*\n')])
+ self.assertEqual('./f*', tree.is_ignored('foo'))
+ self.assertEqual(None, tree.is_ignored('foo/bar'))
+ self.assertEqual(None, tree.is_ignored('foo/.bar'))
+
     def test_global_ignored(self):
         tree = self.make_branch_and_tree('.')

The second one matches.

So it seems our converter from globs to regex isn't probably ignoring the directory in the match.

It seems that because the pattern matches the parent directory, then all the files underneath that directory default to being ignored, even if the parent itself is versioned.

This stems from the fact that we use 'fnmatch.translate()' which translates '*' => '.*' rather than '[^/]*' or something like that.

So I would guess that we have had this bug for a long time, but never had someone who wanted to add files in a directory that would otherwise be ignored.

I certainly have versioned files that would have been ignored, and you can still use 'bzr add .dotfiles/*' to version all of the direct files. Or if you are using zsh, you cand do 'bzr add .dotfiles/**/*'