Skip to content

Commit 0701626

Browse files
authored
Merge pull request #941 from aollier/bzrignore
taking into account the syntax of Bazaar
2 parents d0c4505 + d6cee70 commit 0701626

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

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

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,26 @@ $ 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. "!!" allows you to ignore certain file patterns even if they're specified using a "!" rule.
86+
2. "RE:" at the beginning of a line allows you to specify a https://docs.python.org/3/library/re.html[Python regular expression] (Git only allows shell globs).
87+
88+
As a consequence, there are two different situations to consider:
89+
90+
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: `ln -s .bzrignore .git/info/exclude`
91+
2. Otherwise, you must create the `.git/info/exclude` file and adapt it to ignore exactly the same files in `.bzrignore`.
92+
93+
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`.
94+
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`.
95+
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.
96+
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.
8297

8398
===== Fetch the changes of the remote repository
8499

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+
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 Bazaar was ignoring.
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)