svn2git: fix usage with latest ubuntu svn version
authorrofl0r <[email protected]>
Sun, 14 Jan 2024 23:04:12 +0000 (14 23:04 +0000)
committerrofl0r <[email protected]>
Sun, 14 Jan 2024 23:04:12 +0000 (14 23:04 +0000)
newer svn versions place full copies of each file into a git-like
directory structure in .svn. we don't want these in our git repo,
and now when we do git add '*' after a source file was deleted,
git recognized that the file has been "moved" to
.svn/pristine/aa/bbccddeeff001122334455, which causes
git status --porcelain to print a line like:
R  src/fpu/fpu_load.h -> .svn/pristine/ec/ec26b5f30d239f03eb6c932c8b94658dcf84218d.svn-base
which our previous grep | cut command would misinterpret as having to
delete the first filename printed here.

svn2git.sh

index 63c60a0..9ae3108 100755 (executable)
@@ -90,8 +90,13 @@ git add --all .  # . adds *all* files, even dotfiles and dirs not listed with *,
 
 # unstage our own files from repo
 # we can't check in .gitignore, since that might at some point be added in a commit
-for x in $(git status --porcelain | grep ' \.svnup/' | cut -b 4-) ; do
+for x in $(git status --porcelain | awk '/ \.svn\// || / \.svnup\// {for(i=1;i<=NF;++i) if($i ~ /\.svn\// || $i ~/\.svnup\//) {print($i); break;}}') ; do
 git rm --cached "$x" >/dev/null
+ret=$?
+if test $ret != 0 ; then
+  echo "got error trying to git rm $x"
+  exit 1
+fi
 done
 
 $SVN log -r "$rev" . > "$tmp1"