Is the behaviour of silently adding explicitly-specified ignored files helpful?

Asked by Jim Cheetham

When setting up a new repository, I generally populate the .bzrignore before adding files, which is good.

However, I sometimes say "bzr add *" instead of the more useful "bzr add .", and this causes my ignored files to be added (because TFM says "If a file is explicitly added, it remains versioned regardless of whether it matches an ignore pattern.", and of course the shell is expanding the "*" before bzr add sees the file list)

I'm not sure that this is a good default behaviour. I think it would be more useful for bzr to issue a warning when the user is "explicitly" adding ignored files (appreciating that what's explicit to the bzr command arguments is not necessarily explicit to the shell user). Then the user could check what they are doing, and if they really want to add an ignored file, they could specify some extra argument, like "--add-ignored" ...

This might not add much functionality to old hands, but it might help reduce newbie confusion :-)

Example shell session might look like this :-

$ mkdir ignoretest; cd ignoretest
$ touch goodfile badfile
$ bzr init .
Created a standalone tree (format: 2a)
$ bzr ignore badfile
$ ls
badfile goodfile
$ bzr add *
Warning: adding badfile is prohibited by ignore settings
adding goodfile
$ bzr st
added:
  .bzrignore
  goodfile
$ bzr add --add-ignored badfile
adding badfile
$ bzr st
added:
  .bzrignore
  badfile
  goodfile

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
Martin Pool
Solved:
Last query:
Last reply:
Revision history for this message
Andrew Bennetts (spiv) said :
#1

This isn't a complete answer to your question, but I think our documentation already suggests "bzr add" (with no arguments) and never "bzr add *".

Revision history for this message
Best Martin Pool (mbp) said :
#2

It's a fair point. I think there is already a bug asking for a
warning in this case.

This would be another case of warnings that only new users would want,
therefore it's a bit of a puzzle what the default should be.
--
Martin <http://launchpad.net/~mbp/>

Revision history for this message
Jim Cheetham (jim.cheetham) said :
#3

Well, perhaps keep the warning in place, but don't change the behaviour ...

$ bzr add *
Warning: adding badfile despite ignore settings
adding goodfile

Revision history for this message
Jim Cheetham (jim.cheetham) said :
#4

Would you prefer I lodged a bug/feature request for this, with the warning behaviour?

Revision history for this message
Jim Cheetham (jim.cheetham) said :
#5

Thanks Martin Pool, that solved my question.