This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
sourceforge:git [2018/04/22 12:38] karl Add rebase command, more splits into headlines |
sourceforge:git [2018/04/22 17:02] (current) karl Add script example to fetch and rebase |
||
---|---|---|---|
Line 74: | Line 74: | ||
===== git svn fetch -r 2 svn == | ===== git svn fetch -r 2 svn == | ||
- | Inside this code directory we start to "fetch" revision by revision : | + | 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 $? | ||
Line 118: | Line 119: | ||
===== git svn rebase -l == | ===== git svn rebase -l == | ||
The downloaded files are still kept inside the data pack files; \\ | The downloaded files are still kept inside the data pack files; \\ | ||
- | to make them show up it needs to rebase locally : | + | to make them show up it needs to **rebase locally** : |
<code bash> | <code bash> | ||
git svn rebase -l | git svn rebase -l | ||
Line 151: | Line 152: | ||
git-svn-id: svn://svn.code.sf.net/p/crossfire/code@1 282e977c-c81d-0410-88c4-b93c2d0d6712 | git-svn-id: svn://svn.code.sf.net/p/crossfire/code@1 282e977c-c81d-0410-88c4-b93c2d0d6712 | ||
</code> | </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 ) . | ||
+ |