Bazaar Version Control System

bzr ignore pattern not limited to branch root (as expected)

Reported by Ricardo Kirkner on 2006-08-24
2
Affects Status Importance Assigned to Milestone
Bazaar
Medium
Kent Gibson

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.

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/**/*'

Changed in bzr:
importance: Untriaged → Medium
status: Unconfirmed → Confirmed
John A Meinel (jameinel) wrote :

On the mailing list, we decided the best fix would be just to use a custom glob => regex converter, rather than using fnmatch.translate(). There have been a couple proposals over time, so we should look into using them.

John A Meinel (jameinel) on 2006-10-20
Changed in bzr:
assignee: nobody → warthog618
Kent Gibson (warthog618) on 2006-11-13
Changed in bzr:
status: Confirmed → In Progress
Kent Gibson (warthog618) on 2006-11-15
Changed in bzr:
status: In Progress → Fix Committed
Aaron Bentley (abentley) on 2006-12-19
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers