ignore trailing slash in ignore patterns

Bug #4559 reported by Martin Pool
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
Medium
Unassigned

Bug Description

From: Marius Kruger <email address hidden>

   hi,
   On linux when I do the following with tab completion
   bzr ignore dist/
   it adds a backslash on the end.

   Is it possible to ignore trailing slashes?
   it could be done something like
   p='dist/'
   p=p[:p.rfind(os.sep)]

   OR
   when checking files to ignore
   the matching should match dist/ to dist

   regards
   Marius Kruger

Revision history for this message
Wouter van Heyst (larstiq) wrote :

The above snippet will always delete the last character, so it should at least be:

if name_pattern.endswith(os.sep):
    name_pattern = name_pattern.rstrip(os.sep)

But I'm not convinced this is the right approach, one may want to add os.sep for another platform where it isn't (perhaps far fetched). Would it have value to normalize patterns ending on os.sep to end on '/' and check in matching against such a pattern if we are dealing with a directory or not, or would that be too confusing?

Revision history for this message
Robert Collins (lifeless) wrote :

I think this is reasonable. internally we normalise all code as being '/' separated, so checking for path[-1] == '/' is sufficient. This should be done in the ui layer - in builtins.py.

Changed in bzr:
status: Unconfirmed → Confirmed
Revision history for this message
Martin Pool (mbp) wrote :

Ignoring should probably be done when matching ignore patterns, not when taking in the command line arguments. I don't see what "path/" would otherwise mean.

Revision history for this message
John A Meinel (jameinel) wrote :

I think we can sanitize both times.
Once when reading patterns, and once when adding them to .bzrignore.

This is still an open bug in 0.9, but is not a blocker. I might look into this as part of my ignore updates.

Revision history for this message
John A Meinel (jameinel) wrote :

Kent Gibson wrote a fix for this, which should be available in bzr-0.13

Changed in bzr:
assignee: nobody → warthog618
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.