bzr ignore pattern not limited to branch root (as expected)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Bazaar |
Fix Released
|
Medium
|
Unassigned |
Bug Description
I tried to put my home directory under bzr control. The problem appeared when versioning the dotfiles (.*)
In order to keep things clean, I made a directory named .dotfiles
I wanted to move all dotfiles to this directory, so I could keep my home directory uncluttered.
I issued
bzr ignore "./.*"
on my home directory. This went fine (I mean, the . files got all ignored). Then I manually added the .dotfiles directory using
bzr add .dotfiles
I got the message "ignore 23 file(s)." meaning that all the .* files inside this directory got ignored because of the ignore pattern.
However, according to bzr help ignore, by specifing ./ prefix, this should not have happened.
In order to reproduce this bug, just create a .dotfiles directory with files named .myfile1, .myfile2, etc, and issue bzr ignore "./.*" in .dotfiles parent's directory.
Changed in bzr: | |
assignee: | nobody → warthog618 |
Changed in bzr: | |
status: | Confirmed → In Progress |
Changed in bzr: | |
status: | In Progress → Fix Committed |
Changed in bzr: | |
status: | Fix Committed → Fix Released |
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: tests/workingtr ee_implementati ons/test_ is_ignored. py' tests/workingtr ee_implementati ons/test_ is_ignored. py 2006-07-21 04:02:14 +0000 tests/workingtr ee_implementati ons/test_ is_ignored. py 2006-08-25 01:16:27 +0000
self. assertEqual( None, tree.is_ignored(' xx'))
self. assertEqual( None, tree.is_ ignored( 'subdir/ xx '))
=== modified file 'bzrlib/
--- bzrlib/
+++ bzrlib/
@@ -77,6 +77,13 @@
+ def test_dotfile(self): branch_ and_tree( 'tree') tree_contents( [('tree/ .bzrignore' , './f*\n')]) l('./f* ', tree.is_ ignored( 'foo')) l(None, tree.is_ ignored( 'foo/bar' )) l(None, tree.is_ ignored( 'foo/.bar' )) ignored( self): branch_ and_tree( '.')
+ tree = self.make_
+ self.build_
+ self.assertEqua
+ self.assertEqua
+ self.assertEqua
+
def test_global_
tree = self.make_
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/**/*'