User Tools

Site Tools


sourceforge:git

Git

Git is a revision control system, just like rcs, cvs and subversion (SVN) are.
Though the Crossfire repository is maintained by svn, it is possible to access this svn repo with git.
The subversion package needs to be installed though, since it has bindings for PERL because git-svn is a perl script located in {prefix}/libexec/git-core .

Prerequisites

The bindings of SVN for Perl are available if SWIG is installed.
SVN needs to know where to find the swig binary at compilation time :

./configure --with-swig=/usr/rcs/bin/swig --with-ssl=/usr --with-apr=/usr/rcs --with-apr-util=/usr/rcs --with-neon=/usr/rcs --prefix=/usr/rcs/svn-1.6.23 --with-zlib=/lib --with-serf=/usr/rcs 

When SWIG is available, then after make it needs additionally make swig-pl to compile the SVN perl modules and libraries.
make && make swig-pl && make install && make install-swig-pl should then install the PERL bindings to something like
/usr/lib/perl5/site_perl/5.10.1/i686-linux-thread-multi-ld/SVN directory.

export PERLLIB='/usr/lib/perl5' and export PERL5LIB='/usr/lib/perl5' might be required though, so the perl modules are found.

git svn clone -r 1

Inside a new created directory then run these commands :

git svn clone -r 1 svn://svn.code.sf.net/p/crossfire/code ;echo $?

Which should print to the terminal

Initialized empty Git repository in /mnt/sdb16/CROSSFIRE/svn/git_experiments/code/.git/
W: +empty_dir: trunk
r1 = a967a85ee09bcf27915ff5eb652a10a7dc0d4a89 (refs/remotes/git-svn)
Checked out HEAD:
svn://svn.code.sf.net/p/crossfire/code r1
creating empty directory: trunk
0

And create a directory “code” with a hidden .git/ folder and a trunk/ folder structure.

Inside the .git folder there is a file named config which should look like

[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[svn-remote "svn"]
	url = svn://svn.code.sf.net/p/crossfire/code
	fetch = :refs/remotes/git-svn

Now it needs to change into the new 'code' directory :

cd code

Then run git svn log and git log:

 git svn log                   
------------------------------------------------------------------------
r1 | (no author) | 1999-03-29 03:46:48 -0100 (Mon, 29 Mar 1999) | 2 lines
 
New repository initialized by cvs2svn.
 
------------------------------------------------------------------------
 
 git log
commit c03bc89287c20c60c8d52377771046f54166d4eb (HEAD -> master)
Author: (no author) <(no author)@282e977c-c81d-0410-88c4-b93c2d0d6712>
Date:   Mon Mar 29 04:46:48 1999 +0000
 
    New repository initialized by cvs2svn.
 
    git-svn-id: svn://svn.code.sf.net/p/crossfire/code@1 282e977c-c81d-0410-88c4
-b93c2d0d6712

git svn fetch -r 2 svn

Inside this code directory we start to “fetch” revision by revision until -r5
with an git svn rebase -l after each fetch :

 git svn fetch -r 2 svn;echo $?
	A	trunk/arch/spell/rod_light.111.xpm
	A	trunk/arch/spell/rod_light.arc
	A	trunk/arch/spell/rod_light.112.xpm
	A	trunk/arch/spell/rod_light.113.xpm
	A	trunk/arch/spell/rod_heavy.111
 
	A	trunk/arch/dev/README
	A	trunk/arch/dev/xpm.template
r2 = e8b6556cff76da629a33f2f20c5e3388df081fca (refs/remotes/git-svn)
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
0

When you get errors like

W: Ignoring error from SVN, path probably does not exist: (175002): RA layer request failed: REPORT request >on '/p/crossfire/code/!svn/rvr/2' failed
W: Do not be alarmed at the above message git-svn is just searching aggressively for old history.
This may take a while on large repositories
0hecked through r2

then maybe change the .git/config entry value for the key 'url' from https: to svn:
url = https://svn.code.sf.net/p/crossfire/codeurl = svn://svn.code.sf.net/p/crossfire/code .

When the fetch has finished, then run git svn log :

git svn log
------------------------------------------------------------------------
r2 | uid200 | 1999-03-29 03:46:48 -0100 (Mon, 29 Mar 1999) | 2 lines
 
Initial revision
 
------------------------------------------------------------------------
r1 | (no author) | 1999-03-29 03:46:48 -0100 (Mon, 29 Mar 1999) | 2 lines
 
New repository initialized by cvs2svn.
 
------------------------------------------------------------------------

git svn rebase -l

The downloaded files are still kept inside the data pack files;
to make them show up it needs to rebase locally :

  git svn rebase -l
 
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/git-svn.

Now the trunk/arch folder has some files to view .

Note: Do not forget the -l option for rebase; without that option it would rebase against the HEAD of the svn tree,
downloading all the 20000+ revisions !

And git log tells us :

 git log
commit e8b6556cff76da629a33f2f20c5e3388df081fca (HEAD -> master, git-svn)
Author: uid200 <uid200@282e977c-c81d-0410-88c4-b93c2d0d6712>
Date:   Mon Mar 29 04:46:48 1999 +0000
 
    Initial revision
 
 
    git-svn-id: svn://svn.code.sf.net/p/crossfire/code@2 282e977c-c81d-0410-88c4-b
93c2d0d6712
 
commit c03bc89287c20c60c8d52377771046f54166d4eb
Author: (no author) <(no author)@282e977c-c81d-0410-88c4-b93c2d0d6712>
Date:   Mon Mar 29 04:46:48 1999 +0000
 
    New repository initialized by cvs2svn.
 
    git-svn-id: svn://svn.code.sf.net/p/crossfire/code@1 282e977c-c81d-0410-88c4-b93c2d0d6712

git tag -m "MESSAGE" Tag-Name

When –revision 5 had been fetched, the “initial” commit has been completed and the first changes
to the code will be committed next revision.
Now it is time to –tag it and before adding some meaningful email and user name:

git config user.email anonymouse@puppy.pc
git config user.name anonymouse
git tag -m "Revision -r5: End of initial commits." InitialCommits-r5

git checkout -b trunk

And to make the “trunk” the next “master” :

 git checkout -b trunk
Switched to a new branch 'trunk'
 git branch
  master
* trunk

And from now on until -r 1000 we use this bash script to update until REVISION_UPPER_LIMIT
placed one level outside this code directory :

#!/bin/ash
 
ERROR=${ERROR:=1}
ERR=${ERR:-$ERROR} #ERR var already used as /dev/null OR /dev/stderr
_err(){
test "$ERROR" || return 0
echo -e "$0:ERROR:$*"  >&2
}
 
_exit()
{
local RV
test "$*" || { _err "Usage:_exit EXITCODE MESSAGE"; }
RV=$1
[ "${RV//[[:digit:]]/}" ] && { _err "\$1 must be a digit number."; RV=255; } || shift
echo "$*" >&2
case ${MY_SELF##*/} in
ash*|bash*|sh*) return $RV;;
*) exit $RV;;
esac
}
 
REVISION_UPPER_LIMIT=1000
 
cd code || _exit 1 "Unable to change cd into dir code/ ."
 
git checkout trunk || _exit 3 "Could not checkout trunk."
 
cd trunk || _exit 1 "Unable to change cd into dir trunk/ ."
 
git svn rebase -l || _exit 9 "Could not rebase beforehand."
 
INFO=`git svn info` || _exit 2 "git svn info returned '$?' ."
REVISION=`echo "$INFO" | grep -m 1 '^Revision:' | awk '{print $2}'`
 
test "$REVISION" || _exit 5 "Could not obtain Revision Number."
test "${REVISION//[0-9]/}" && _exit 6 "Revision Number not a number."
 
REVISION=$((REVISION + 1))
 
test $REVISION -lt $REVISION_UPPER_LIMIT || _exit 7 "Revision $REVISION greater-equal REVISION_UPPER_LIMIT $REVISION_UPPER_LIMIT . Nothing to do."
 
for r in `seq $REVISION 1 $REVISION_UPPER_LIMIT`
do
 
 c=0
 while :; do
  git svn fetch -r $r svn  && break 1
  c=$((c+1))
  test $c -gt 9 && break 2
  sleep 2
 done
 
 git svn rebase -l || break 1
 
sleep 1
done
 
echo
echo $0 finished after fetching revision $r

The above code will take some time, expect 5 seconds each fetch ( 6000 sec = 100 minutes ) .

sourceforge/git.txt · Last modified: 2018/04/22 17:02 by karl