[asterisk-dev] following asterisk with git-svn

Tzafrir Cohen tzafrir.cohen at xorcom.com
Mon Feb 16 16:18:23 CST 2009


Hi

git-svn is an interface for the git version control system
(http://git-scm.com/) . It basically creates a git copy of a subversion
repository.

Why use it?

* Working off-line:
  If you want to be able to use 'svn log' and 'svn diff' to a different
  branch, now you can.

* Efficient repository browser:
  With git you can effectively browse commit logs and working copies of
  various branches. In fact, using it merely as a logs and versions
  browser can be useful on its own.

* Branches really work
  With SVN merging a branch is complicated. Partially because lack of
  separate merge tracking.With git you don't need the extra svnmerge:
  changes that don't collide with your branch merge in a quick merge
  operation.

Limitations:

* svn:externals
  does not really work well with git-svn (and similar systems: svk, 
  bzr-svn and hg-svn). Git has something called submodules that allows 
  emulating the basic functionality of svn:externals, but is not as 
  transparent.

* Commiting:
  Not sure how safe it is to commit from such a copy. In most places I
  see that it is not recommended to commit directly from git-svn. OTOH,
  git has some tools that make it easy to prepare a patch set out of a
  branch (e.g. git format-patch).

  IIRC there are also some issues for git-svn with https certificate
  authentication in the first place.

* Tags:
  /tags are branches. SVN tags are really branches that we pretend not
  to change. And in fact in Asterisk we practically do change. But see
  workaround below to generate tags from the tag branches.

* /team branches:
  At least with git 1.5.x you can't easily follow all the team branches.
  This is due to a bug in their handling of wildcards in branches 
  description. I believe this has been resolved in 1.6 but I didn't get
  to test that. Even if it will, it will require an extra step of manual
  editing. 


So now off to work:

Make sure you have the package 

  git-svn

installed. It is part of the standard git distribution and included in
any recent Linux distribution.

# select a place under which to download the asterisk tree.

  git svn clone -s http://svn.digium.com/svn/asterisk

# This will download the whole /trunk , /tags and /branches hirarchies 
# to a new git repository under asterisk/ . 
# This will take a L  O  N  G time. In the order of magnitude of a
# day. If it stops: in the middle:
#cd asterisk; git svn fetch --fetch-all

# Next make your repository more compact:
# FIXME: I now get a .git subdirectory of the size of 135MB . This seems
# overly large considering what I got a few monthes ago

  git repack -a

# Now fix the menuselect bits. One possible venue is to use submodules.
# This would require setting a separate menuselect repository . And
# fixing the submodule references in every new tag to point to the right
# place. I gave up at this stage, and instead reimplememented menuselect

  mkdir menuselect
  svn export http://svn.digium.com/svn/menuselect/trunk/contrib/Makefile-dummy menuselect/Makefile
  svn export http://svn.digium.com/svn/menuselect/trunk/contrib/menuselect-dummy menuselect/menuselect
  make -C menuselect dummies
  chmod +x menuselect/menuselect

# Note that this version of menuselect still needs fixing at the time of
# writing this. See http://bugs.digium.com/view.php?id=13132
# and http://tzafrir.org.il/~tzafrir/menuselect/

# Next thing to do is ignore generated files. .gitignore is somewhat
# like svn:ignore . Though it is possible to use one at the top
# directory. Hence I decided to make it ignore itself as well:

cat <<EOF >.gitignore
# Ignoring .gitignore itself:
.gitignore
menuselect
build_tools/menuselect-deps
channels/h323/Makefile
config.log
config.status
include/asterisk/autoconfig.h
makeopts
.lastclean
agi/eagi-sphinx-test
agi/eagi-test
agi/strcompat.c
build_tools/conf
build_tools/dump_deps
# The '*' here stands for a literal *. Bug?
channels/h323/*.dep
channels/h323/Makefile.ast
defaults.h
include/asterisk/build.h
include/asterisk/buildopts.h
include/asterisk/version.h
main/version.c
makeopts.embed_rules
menuselect-tree
menuselect.makedeps
utils/aelbison.c
utils/aelparse
utils/aelparse.c
utils/ast_expr2.c
utils/ast_expr2f.c
utils/astcanary
utils/astman
utils/astobj2.c
utils/check_expr
utils/conf2ael
utils/hashtab.c
utils/hashtest
utils/hashtest2
utils/md5.c
utils/muted
utils/pbx_ael.c
utils/pval.c
utils/refcounter
utils/sha1.c
utils/smsq
utils/stereorize
utils/strcompat.c
utils/streamplayer
utils/threadstorage.c
utils/utils.c
utils/strings.c
doc/*.xml
main/asterisk
main/editline/Makefile
main/editline/common.h
main/editline/config.cache
main/editline/config.h
main/editline/editline.c
main/editline/editline.o_a
main/editline/emacs.h
main/editline/fcns.c
main/editline/fcns.h
main/editline/help.c
main/editline/help.h
main/editline/makelist
main/editline/vi.h
sounds/*.tar.gz
*.o.d
*.o
*.oo.d
*.oo
*.o_a
*.makeopts
*.moduleinfo
*.so
*.a
# Because you use the right editor:
.*.swp
EOF

# Still with me? great :-)
# Now let's generate tags that will point to the tags/* branches.
# e.g. tag 'v1.4.8' will point to the head of branch tags/1.4.8 .
# If you don't like the extra 'v', just edit the sed command.
git branch -r | grep tags/1 | sed -e 's"tags/\(.*\)"& v\1"' \
  | while read branch tag; do git tag $tag $branch; done

# Example configuration (refer to menuselect/menuselelct for more
# information)
# Please don't break my build:
echo 'exclude chan_h323' >build_tools/conf


Now you have your own tree. Use ./configure; make; make insstall # and
whatever.

If you use git from the command-line, it is highly recommended to enable
programmable bash completion. The git command-line is way more complex
than svn, but the completion makes it usable:

  asterisk$ git show v1.2.28<tab><tab>
  v1.2.28     v1.2.28.1
  
  asterisk$ git show v1.2.28:c<tab><tab>
  callerid.c     channel.c      cli.c          coef_out.h     contrib/
  cdr/           channels/      codecs/        config.c       cryptostub.c
  cdr.c          chanvars.c     coef_in.h      configs/       cygwin/

  asterisk$ git svn<tab><tab>
  clone            fetch            log              set-tree
  commit-diff      find-rev         propget          show-externals
  create-ignore    info             proplist         show-ignore
  dcommit          init             rebase

  asterisk$ git svn rebase --f
  --fetch-all       --follow-parent

Some useful commands:

  git svn rebase --fetch-all # pull updates from upstream
  man git-FOO                # documentation for 'git FOO'
  # <tree> is any place on graph of branches: HEAD, name of a branch or
  # a tag, commit ID, and some others
  git show <tree>            # The top commit in this tree (log + diff)
  git show <tree>:directory  # directory listing
  git show <tree>:some/file  # get that file
  git log <tree>             # commit log up to that point
  git branch                 # shows local branches and in which one you are
  git branch -r              # List remote branches. Such are SVN ones.

-- 
               Tzafrir Cohen
icq#16849755              jabber:tzafrir.cohen at xorcom.com
+972-50-7952406           mailto:tzafrir.cohen at xorcom.com
http://www.xorcom.com  iax:guest at local.xorcom.com/tzafrir



More information about the asterisk-dev mailing list