User Tools

Site Tools


sourceforge:git

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
sourceforge:git [2018/04/21 18:08]
karl Add git svn log, fix several typos
sourceforge:git [2018/04/22 17:02] (current)
karl Add script example to fetch and rebase
Line 1: Line 1:
 ====== Git ====== ====== Git ======
  
-Git is a revision control system, just like rcs, cvs and [[svn]] are. \\+Git is a revision control system, just like rcs, cvs and [[svn|subversion (SVN)]] are. \\
 Though the Crossfire repository is maintained by svn, it is possible to access this svn repo with git. \\ Though the Crossfire repository is maintained by svn, it is possible to access this svn repo with git. \\
-The svn package needs to be installed though, since it has bindings for PERL because git-svn is a perl script.+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 == ===== Prerequisites ==
Line 23: Line 23:
 Inside a new created directory then run these commands : Inside a new created directory then run these commands :
 <code bash> <code bash>
-git svn clone -r 1 https://​svn.code.sf.net/​p/​crossfire/​code ;echo $?+git svn clone -r 1 svn://​svn.code.sf.net/​p/​crossfire/​code ;echo $?
 </​code>​ </​code>​
 Which should print to the terminal Which should print to the terminal
->​Initialized empty Git repository in /​mnt/​sdb16/​CROSSFIRE/​client_svn/​git_experiments/​code/​.git/​+>​Initialized empty Git repository in /​mnt/​sdb16/​CROSSFIRE/​svn/​git_experiments/​code/​.git/​
 >W: +empty_dir: trunk >W: +empty_dir: trunk
 >r1 = a967a85ee09bcf27915ff5eb652a10a7dc0d4a89 (refs/​remotes/​git-svn) >r1 = a967a85ee09bcf27915ff5eb652a10a7dc0d4a89 (refs/​remotes/​git-svn)
 >Checked out HEAD: >Checked out HEAD:
->  ​https://​svn.code.sf.net/​p/​crossfire/​code r1+>  ​svn:%%//%%svn.code.sf.net/​p/​crossfire/​code r1
 >​creating empty directory: trunk >​creating empty directory: trunk
 >0 >0
-And create a directory "​code"​ with a hidden .git folder structure.+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 
 +<code conf> 
 +[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 
 +</​code>​
  
 Now it needs to change into the new '​code'​ directory : Now it needs to change into the new '​code'​ directory :
Line 40: Line 52:
 </​code>​ </​code>​
  
-Now run git svn log :+Then run git svn log and git log:
 <code bash> <code bash>
  git svn log                     git svn log                   
Line 49: Line 61:
  
 ------------------------------------------------------------------------ ------------------------------------------------------------------------
 +
 + 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
 </​code>​ </​code>​
  
-Inside this code directory we start to "​fetch"​ revision by revision :+===== 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 :
 <code bash> <code bash>
  git svn fetch -r 2 svn;echo $?  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
 </​code>​ </​code>​
 +
 +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: 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. >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 >This may take a while on large repositories
 >0hecked through r2 >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/​code''​ -> ''​url = svn:​%%//​%%svn.code.sf.net/​p/​crossfire/​code''​ .
  
  
-And then the files start to appear with revision 3 :+When the fetch has finished, then run git svn log :
 <code bash> <code bash>
-git svn fetch -r 3 svn;echo $? +git svn log 
- A trunk/​arch/​gods/​supernatural/​valriel.arc +-----------------------------------------------------------------------
- A trunk/​arch/​gods/​supernatural/​devourers.arc +r2 | uid200 | 1999-03-29 03:46:48 -0100 (Mon, 29 Mar 1999) | 2 lines 
- A trunk/​arch/​gods/​supernatural/​gorokh.arc + 
- A trunk/​arch/​gods/​elemental/​ruggilli.111 +Initial revision 
- A trunk/​arch/​gods/​elemental/​ruggilli.211 + 
- A trunk/​arch/​gods/​elemental/​ruggilli.112 +------------------------------------------------------------------------ 
- A trunk/​arch/​skills/​singing.arc+r1 | (no author) | 1999-03-29 03:46:48 -0100 (Mon, 29 Mar 1999) | 2 lines 
 + 
 +New repository initialized by cvs2svn. 
 + 
 +------------------------------------------------------------------------
 </​code>​ </​code>​
 +
 +===== 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** :
 +<code bash>
 +  git svn rebase -l
 +
 +First, rewinding head to replay your work on top of it...
 +Fast-forwarded master to refs/​remotes/​git-svn.
 +</​code>​
 +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 :
 +<code bash>
 + 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
 +</​code>​
 +
 +===== 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:
 +<code bash>
 +git config user.email anonymouse@puppy.pc
 +git config user.name anonymouse
 +git tag -m "​Revision -r5: End of initial commits."​ InitialCommits-r5
 +</​code>​
 +
 +===== git checkout -b trunk ==
 +
 +And to make the "​trunk"​ the next "​master"​ :
 +<code bash>
 + git checkout -b trunk
 +Switched to a new branch '​trunk'​
 + git branch
 +  master
 +* trunk
 +</​code>​
 +
 +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 :
 +<code bash>
 +#!/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
 +</​code>​
 +
 +The above code will take some time, expect 5 seconds each fetch ( 6000 sec = 100 minutes ) . 
  
sourceforge/git.1524352125.txt.gz · Last modified: 2018/04/21 18:08 by karl