trailing whitespace in .bzrignore is not ignored

Bug #174607 reported by David Roberts
2
Affects Status Importance Assigned to Milestone
Bazaar
Confirmed
Low
Unassigned

Bug Description

.bzrignore file appears not to be honoured.

To demonstrate -

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

H:\>mkdir bzr

H:\>cd bzr

H:\bzr>bzr --version
Bazaar (bzr) 1.0.0.candidate.1
  Python interpreter: C:\Added Program Files\Bazaar\python25.dll 2.5.1.final.0
  Python standard library: C:\Added Program Files\Bazaar\lib\library.zip
  bzrlib: C:\Added Program Files\Bazaar\lib\library.zip\bzrlib
  Bazaar configuration: C:\Documents and Settings\David\Application Data\bazaar\2.0
  Bazaar log file: C:\Documents and Settings\David\My Documents\.bzr.log

Copyright 2005, 2006, 2007 Canonical Ltd.
http://bazaar-vcs.org/

bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
you may use, modify and redistribute it under the terms of the GNU
General Public License version 2 or later.

H:\bzr>bzr init

H:\bzr>echo *.txt > .bzrignore

H:\bzr>echo content > filename.txt

H:\bzr>bzr status
unknown:
  .bzrignore
  filename.txt

H:\bzr>bzr ignored

H:\bzr>bzr add
added .bzrignore
added filename.txt

H:\bzr>bzr commit -m"this file should have been ignored"
Committing revision 1 to "H:/bzr/".
added .bzrignore
added filename.txt
Committed revision 1.

H:\bzr>bzr log
------------------------------------------------------------
revno: 1
committer: David Roberts <email address hidden>
branch nick: bzr
timestamp: Fri 2007-12-07 08:24:24 +0000
message:
  this file should have been ignored

H:\bzr>type .bzrignore
*.txt

 ==============================================================

I expected "*.txt" in .bzrignore to be a match for a file
named "filename.txt", and thus for that file not to be
versioned or committed.

Revision history for this message
Dan Watkins (oddbloke) wrote :

I can't reproduce this on Debian, running bzr.dev r3042.

Revision history for this message
Alexander Belchenko (bialix) wrote : Re: [Bug 174607] .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

David Roberts пишет:
> Public bug reported:
>
> .bzrignore file appears not to be honoured.
>
> To demonstrate -
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> H:\>mkdir bzr
>
> H:\>cd bzr
>
> H:\bzr>bzr --version
> Bazaar (bzr) 1.0.0.candidate.1
> Python interpreter: C:\Added Program Files\Bazaar\python25.dll 2.5.1.final.0
> Python standard library: C:\Added Program Files\Bazaar\lib\library.zip
> bzrlib: C:\Added Program Files\Bazaar\lib\library.zip\bzrlib
> Bazaar configuration: C:\Documents and Settings\David\Application Data\bazaar\2.0
> Bazaar log file: C:\Documents and Settings\David\My Documents\.bzr.log
>
> Copyright 2005, 2006, 2007 Canonical Ltd.
> http://bazaar-vcs.org/
>
> bzr comes with ABSOLUTELY NO WARRANTY. bzr is free software, and
> you may use, modify and redistribute it under the terms of the GNU
> General Public License version 2 or later.
>
>
> H:\bzr>bzr init
>
> H:\bzr>echo *.txt > .bzrignore

^-- The problem is here.
win32 echo command wrote to .bzrignore exact string that ends at '>'
sign, i.e. actually "*.txt ". So bzr try to match against file extension
"txt ". Because on windows you cannot create files with trailing spaces
this behavior is incorrect on windows. But pattern itself is probably
correct for linux.

But if you actually invoke your command as:

echo *.txt> .bzrignore

then all works fine.

I'm not sure how to fix this in cross-platform way. I even not sure we
should fix this, because actually

bzr ignore *.txt

do the right thing.

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote : Re: [Bug 174607] .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

Alexander Belchenko wrote:

>> H:\bzr>echo *.txt > .bzrignore
>
> ^-- The problem is here.
> win32 echo command wrote to .bzrignore exact string that ends at '>'
> sign, i.e. actually "*.txt ". So bzr try to match against file extension
> "txt ". Because on windows you cannot create files with trailing spaces
> this behavior is incorrect on windows. But pattern itself is probably
> correct for linux.
>
> But if you actually invoke your command as:
>
> echo *.txt> .bzrignore
>
> then all works fine.
>
> I'm not sure how to fix this in cross-platform way.

Sounds like trailing spaces in .bzrignore file should be trimmed. I
can't think of a good reason for not doing that.

Ian C.

Revision history for this message
David Roberts (smartgpx) wrote : Re: [Bug 174607] .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

On 07/12/2007, Ian Clatworthy <email address hidden> wrote:
> Alexander Belchenko wrote:
>
> >> H:\bzr>echo *.txt > .bzrignore
> >
> > ^-- The problem is here.
> > win32 echo command wrote to .bzrignore exact string that ends at '>'
> > sign, i.e. actually "*.txt ". So bzr try to match against file extension
> > "txt ". Because on windows you cannot create files with trailing spaces
> > this behavior is incorrect on windows. But pattern itself is probably
> > correct for linux.
> >
> > But if you actually invoke your command as:
> >
> > echo *.txt> .bzrignore
> >
> > then all works fine.
> >
> > I'm not sure how to fix this in cross-platform way.
>
> Sounds like trailing spaces in .bzrignore file should be trimmed. I
> can't think of a good reason for not doing that.
>
> Ian C.
>

Although my reaction to the 'feature' I have tripped over is "Aargh!",
I have to say I think the 'trailing spaces' fix is pragmatic but not
necessarily 'correct'. Having just been to look this up, I find to my surprise
that on *nix (posix?) filestores trailing white-space is syntactically
valid. In
which case a pattern that might match such a file must logically also be valid.

On Windows, it seems that trailing spaces in filenames are valid
for NTFS, but not for the win32 subsystem.

And the .bzrignore file should be versioned, so will be in the
branch, so might be transported from one OS to another...

Oh dear, I think I've wandered into a cross-platform minefield,
and maybe this should be closed as "Erroneous User Expectation"
rather than "Bug".

Sorry!

DJ

> --
> .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]
> https://bugs.launchpad.net/bugs/174607
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote : Re: [Bug 174607] .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

David Roberts wrote:

> Although my reaction to the 'feature' I have tripped over is "Aargh!",
> I have to say I think the 'trailing spaces' fix is pragmatic but not
> necessarily 'correct'. Having just been to look this up, I find to my surprise
> that on *nix (posix?) filestores trailing white-space is syntactically
> valid. In
> which case a pattern that might match such a file must logically also be valid.
>
> On Windows, it seems that trailing spaces in filenames are valid
> for NTFS, but not for the win32 subsystem.

I'm pretty sure .bzrignore supports regular expressions by starting
lines with RE:. If that's true, we can still trim trailing spaces on the
basis that users can enter an RE if they really, really want to specify
a pattern with a trailing space. (The RE can terminate with $ after such
a space.)

Ian C.

Revision history for this message
John A Meinel (jameinel) wrote : Re: .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

On windows, it will silently remove trailing whitespace from filenames under certain conditions. We have a test that our Bundle code is able to send a filename that ends in a whitespace and it will be correctly seen when merging that patch. And it was failing on Windows for some reason.... Took a bit to track that down.

IIRC, it was doing it for both NTFS and FAT32.

So I see a couple possibilities:

a) Strip whitespace from the ignore patterns when reading from .bzrignore (if we are going to do trailing whitespace, I would do leading whitespace, too)

b) Strip whitespace from the command line arguments to "bzr ignore". That doesn't help people who use "echo" though.

I'd probably like to do both...

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

this isn't just true on win32, but it is more likely to happen because of difference is "echo" semantics.

Changed in bzr:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
David Roberts (smartgpx) wrote : Re: [Bug 174607] Re: trailing whitespace in .bzrignore is not ignored

Just to say thank you for the attention this has received. Once a bug
is on a bug tracker it is in the public domain and no longer 'mine',
but I am content with the revised description and suggested
solution(s).

DJ

PS: Not a bzr issue at all, but I had always assumed that the Windows
command line had white-space delimited arguments - it never occured to
me that the whitespace was handed on as part of the argument! So I've
learnt something - thanks.

On 07/12/2007, John A Meinel <email address hidden> wrote:
> this isn't just true on win32, but it is more likely to happen because
> of difference is "echo" semantics.
>
> ** Changed in: bzr
> Importance: Undecided => Low
> Status: New => Triaged
>
> --
> trailing whitespace in .bzrignore is not ignored
> https://bugs.launchpad.net/bugs/174607
> You received this bug notification because you are a direct subscriber
> of the bug.
>

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 174607] Re: .bzrignore is not honoured. [Bazaar (bzr) 1.0.0.candidate.1 - win32]

On Dec 8, 2007 4:45 AM, John A Meinel <email address hidden> wrote:
> So I see a couple possibilities:
>
> a) Strip whitespace from the ignore patterns when reading from
> .bzrignore (if we are going to do trailing whitespace, I would do
> leading whitespace, too)
>
> b) Strip whitespace from the command line arguments to "bzr ignore".
> That doesn't help people who use "echo" though.

Trailing whitespace is invisible, so more difficult for people to debug.

I believe that at present we accept \ as an escape character in ignore
patterns, and maybe that should allow you to include whitespace, as it
does on the shell command line.

--
Martin

Martin Pool (mbp)
Changed in bzr:
status: Triaged → Confirmed
Revision history for this message
Tom Browder (tbrowder) wrote :

I was going to file a bug until I found this open one: .bzrignore file leading whitespace is NOT ignored. For example, given a line like this in the .bzrignore file:

  Makefile

results in file "Makefile" not being ignored; however, this line works:

Makefile

So please trim or ignore leading whitespace.

Jelmer Vernooij (jelmer)
tags: added: ignore
Jelmer Vernooij (jelmer)
tags: added: check-for-breezy
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers