Skip to content

Commit 209d2a5

Browse files
committed
taking into account the syntax of Bazaar
Bazaar has a more extended syntax than Git to ignore some files. Then it is necessary to adapt the exclusion file of the Git repository to take into account the possible incompatibilities.
1 parent b04a01a commit 209d2a5

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

book/09-git-and-other-scms/sections/client-bzr.asc

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,28 @@ $ git fetch
7474

7575
===== Ignore what is ignored with .bzrignore
7676

77-
As the format of the `.bzrignore` file is completely compatible with `.gitignore`'s one, and as you shouldn't make a `.gitignore` file in your repository, it is enough to make a symbolic link to `.bzrignore` so that the potential changes of `.bzrignore` are taken into account:
78-
[source,console]
79-
----
80-
$ ln -s .bzrignore .git/info/exclude
81-
----
77+
Since you are working on a project managed with Bazaar, you shouldn't create a `.gitignore` file because you _may_ accidentally set it under version control and the other people working with Bazaar would be disturbed.
78+
The solution is to create the `.git/info/exclude` file either as a symbolic link or as a regular file.
79+
We'll see later on how to solve this question.
80+
81+
Bazaar uses the same model as Git to ignore files, but also has two features which don't have an equivalent into Git.
82+
The complete description may be found in http://doc.bazaar.canonical.com/bzr.2.7/en/user-reference/ignore-help.html[the documentation].
83+
The two features are:
84+
85+
1. "!!" at the beginning of a character string takes prevail on "!" at the beginning of the string, which allows to ignore some files that would have been included with "!"
86+
2. character strings starting with "RE:".
87+
What follows "RE:" is a http://doc.bazaar.canonical.com/bzr.2.7/en/user-reference/patterns-help.html[regular expression].
88+
Git does not allow the use of regular expressions, only shell globs.
89+
90+
As a consequence, there are two different situations to consider:
91+
92+
1. If the `.bzrignore` file does not contain any of these two specific prefixes, then you can simply make a symbolic link to it in the repository.
93+
2. Otherwise, you must create the `.git/info/exclude` file and adapt it to ignore exactly the same files in `.bzrignore`.
94+
95+
Whatever the case is, you will have to remain vigilant against any change of `.bzrignore` to make sure that the `.git/info/exclude` file always reflects `.bzrignore`.
96+
Indeed, if the `.bzrignore` file were to change and contained one or more lines starting with "!!" or "RE:", Git not being able to interpret these lines, you'll have to adapt your `.git/info/exclude` file to ignore the same files as the ones ignored with `.bzrignore`.
97+
Moreover, if the `.git/info/exclude` file was a symbolic link, you'll have to first delete the symbolic link, copy `.bzrignore` to `.git/info/exclude` and then adapt the latter.
98+
However, be careful with its creation because with Git it is impossible to re-include a file if a parent directory of that file is excluded.
8299

83100
===== Fetch the changes of the remote repository
84101

book/09-git-and-other-scms/sections/import-bzr.asc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,15 @@ $ git reset --hard HEAD
129129
===== Ignoring the files that were ignored with .bzrignore
130130

131131
Now let's have a look at the files to ignore.
132-
As `.bzrignore`'s format is completely compatible with `.gitignore`'s format, the simplest is to rename your `.bzrignore` file.
133-
You will also have to create a commit that contains this change for the migration:
132+
The first thing to do is to rename `.bzrignore` into `.gitignore`.
133+
Moreover, if the `.bzrignore` file contains one or several lines starting with "!!" or "RE:", you'll have to modify it and perhaps create several `.gitignore` files in order to ignore exactly the same files that `.bzrignore` allowed.
134+
135+
Finally, you will have to create a commit that contains this modification for the migration:
134136

135137
[source,console]
136138
----
137139
$ git mv .bzrignore .gitignore
140+
$ # modify .gitignore if needed
138141
$ git commit -am 'Migration from Bazaar to Git'
139142
----
140143

0 commit comments

Comments
 (0)