2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2009, Digium, Inc.
6 * See http://www.asterisk.org for more information about
7 * the Asterisk project. Please do not directly contact
8 * any of the maintainers of this project for assistance;
9 * the project provides a web site, mailing lists and IRC
10 * channels for your use.
12 * This program is free software, distributed under the terms of
13 * the GNU General Public License Version 2. See the LICENSE file
14 * at the top of the source tree.
22 * \page AsteriskGitHowto How to setup a local GIT mirror of the Asterisk SVN repository
26 * \section Introduction Introduction
27 * This document will instruct you how to setup a local git mirror of the
28 * Asterisk SVN repository.
30 * Why would you want that? for starters, it's a fast repository browser
31 * and works well even when offline. More on why and why not at 'Pros and Cons'
32 * in the end of this document.
35 * \section Setup Setup
37 * Make sure you have the package
43 * installed. It is part of the standard git distribution and included in
44 * any recent Linux distribution.
46 * Next, get the files from this repository:
49 git clone http://git.tzafrir.org.il/git/asterisk-tools.git
52 * Which will create the subdirectory 'asterisk-tools' under your working
53 * directory. For the purpose of this HOWTO I assume that you will later
54 * download Asterisk under the same directory.
56 * Now let's get Asterisk:
59 git svn clone -s http://svn.digium.com/svn/asterisk
62 * This will download the whole /trunk , /tags and /branches hirarchies
63 * to a new git repository under asterisk/ .
64 * This will take a L O N G time. In the order of magnitude of a
65 * day. If it stops in the middle:
68 # cd asterisk; git svn fetch --fetch-all
71 * All commands as of this point are run from the newly-created subdirectory
78 * Next make your repository more compact:
80 * \note FIXME: I now get a .git subdirectory of the size of 135MB. This seems
81 * overly large considering what I got a few monthes ago.
87 * Now fix the menuselect bits. One possible venue is to use submodules.
88 * This would require setting a separate menuselect repository . And
89 * fixing the submodule references in every new tag to point to the right
90 * place. I gave up at this stage, and instead reimplememented menuselect
93 cp -a ../asterisk-tools/menuselect menuselect
94 make -C menuselect dummies
95 chmod +x menuselect/menuselect
98 * Next thing to do is ignore generated files. .gitignore is somewhat
99 * like svn:ignore . Though it is possible to use one at the top
100 * directory. Hence I decided to make it ignore itself as well:
103 cp ../asterisk-tools/asterisk_gitignore .gitignore
106 * Now let's generate tags that will point to the tags/* branches.
107 * e.g. tag 'v1.4.8' will point to the head of branch tags/1.4.8 .
108 * If you don't like the extra 'v', just edit the sed command.
111 ../asterisk-tools/update_tags
114 * Example configuration (refer to menuselect/menuselelct for more
115 * information). For instance: res_snmp breaks building 1.4 from git:
118 echo 'exclude res_snmp' >build_tools/conf
123 * \section Update Update
124 * The main Asterisk repository tends to get new commits occasionally. I
125 * suppose you want those updates in your local copy. The following command
126 * should normally be done from the master branch. If you actually use branches,
127 * it is recommended to switch to it beforehand:
133 * Next, get all updates.
136 * \section Usage Usage
138 * If you use git from the command-line, it is highly recommended to enable
139 * programmable bash completion. The git command-line is way more complex
140 * than svn, but the completion makes it usable:
144 asterisk$ git show v1.2.28<tab><tab>
147 asterisk$ git show v1.2.28:c<tab><tab>
148 callerid.c channel.c cli.c coef_out.h contrib/
149 cdr/ channels/ codecs/ config.c cryptostub.c
150 cdr.c chanvars.c coef_in.h configs/ cygwin/
152 asterisk$ git svn<tab><tab>
153 clone fetch log set-tree
154 commit-diff find-rev propget show-externals
155 create-ignore info proplist show-ignore
158 asterisk$ git svn rebase --f
159 --fetch-all --follow-parent
162 * Some useful commands:
165 git svn rebase --fetch-all # pull updates from upstream
166 man git-FOO # documentation for 'git FOO'
167 # <tree> is any place on graph of branches: HEAD, name of a branch or
168 # a tag, commit ID, and some others
169 git show <tree> # The top commit in this tree (log + diff)
170 git show <tree>:directory # directory listing
171 git show <tree>:some/file # get that file
172 git log <tree> # commit log up to that point
173 git branch # shows local branches and in which one you are
174 git branch -r # List remote branches. Such are SVN ones.
177 * For more information, see the man page gittutorial as well as
178 * \arg http://git-scm.com/documentation
181 git svn rebase --fetch-all
186 * \section ProsAndCons Pros and Cons
188 * \subsection TheGood The Good
191 * If you want to be able to use 'svn log' and 'svn diff' to a different
192 * branch, now you can.
194 * Efficient repository browser:
195 * With git you can effectively browse commit logs and working copies of
196 * various branches. In fact, using it merely as a logs and versions
197 * browser can be useful on its own.
199 * Branches really work:
200 * With SVN merging a branch is complicated. Partially because lack of
201 * separate merge tracking.With git you don't need the extra svnmerge:
202 * changes that don't collide with your branch merge in a quick merge
205 * \subsection Limitations Limitations
208 * does not really work well with git-svn (and similar systems: svk,
209 * bzr-svn and hg-svn). Git has something called submodules that allows
210 * emulating the basic functionality of svn:externals, but is not as
214 * Not sure how safe it is to commit from such a copy. In most places I
215 * see that it is not recommended to commit directly from git-svn. OTOH,
216 * git has some tools that make it easy to prepare a patch set out of a
217 * branch (e.g. git format-patch).
219 * IIRC there are also some issues for git-svn with https certificate
220 * authentication in the first place.
223 * /tags are branches. SVN tags are really branches that we pretend not
224 * to change. And in fact in Asterisk we practically do change. But see
225 * workaround below to generate tags from the tag branches.
228 * At least with git 1.5.x you can't easily follow all the team branches.
229 * This is due to a bug in their handling of wildcards in branches
230 * description. I believe this has been resolved in 1.6 but I didn't get
231 * to test that. Even if it will, it will require an extra step of manual