git-migration: cvs2git_fixes.sh - remove unlabeled branch if pointed by ano...
draenog
draenog at pld-linux.org
Tue Apr 5 15:25:36 CEST 2011
Author: draenog Date: Tue Apr 5 13:25:36 2011 GMT
Module: git-migration Tag: HEAD
---- Log message:
- remove unlabeled branch if pointed by another tag or branch
---- Files affected:
git-migration:
cvs2git_fixes.sh (1.9 -> 1.10)
---- Diffs:
================================================================
Index: git-migration/cvs2git_fixes.sh
diff -u git-migration/cvs2git_fixes.sh:1.9 git-migration/cvs2git_fixes.sh:1.10
--- git-migration/cvs2git_fixes.sh:1.9 Mon Feb 14 14:32:29 2011
+++ git-migration/cvs2git_fixes.sh Tue Apr 5 15:25:31 2011
@@ -6,7 +6,8 @@
#
# Branches which are no longer labelled can exist in CVS. cvs2git names them
# unlabeled-<revision>. The script changes "unlabeled" to specified name or
-# deleted them if name is unspecified
+# deleted them if name is unspecified. Such a branch is also deleted if it is pointed
+# by another tag or named branch.
# Often in CVS repo only changed file are tagged. In this case cvs2git produces
# superfluous commits to delete not tagged file. Here the tag in converted git
@@ -16,18 +17,28 @@
# 3. the tag is not on any branch
name=$1
+file_tags=$(mktemp tags.XXXXXX)
+file_heads=$(mktemp heads.XXXXXX)
-git show-ref --heads | grep -E 'unlabeled-[0-9.]+$' | \
+git show-ref --tags -d > $file_tags
+git show-ref --heads > $file_heads
+
+grep -E 'unlabeled-[0-9.]+$' $file_heads | \
while read rev branchname; do
if [ -z "$name" ]; then
git update-ref -d "$branchname" $rev
else
+ cat $file_tags
+ if ! grep "^$rev" $file_heads $file_tags | grep -v refs/heads/unlabeled- ; then
new_branchname=`echo $branchname | sed -e "s/refs\/heads\/unlabeled-\([0-9.]\+\)$/${name}-\1/"`
git update-ref "refs/tags/$new_branchname" $rev "" && git update-ref -d "$branchname" $rev
+ else
+ git update-ref -d "$branchname" $rev
+ fi
fi
done
-git show-ref --tags | \
+cat $file_tags | \
while read rev tagname; do
if [ "`git show --format="%an" --quiet $rev`" = "cvs2svn" ]; then
git diff-tree --diff-filter=ACMRTUXB --quiet $rev~ $rev && \
@@ -35,4 +46,5 @@
git update-ref "$tagname" $rev~
fi
done
+rm $file_tags $file_heads
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/git-migration/cvs2git_fixes.sh?r1=1.9&r2=1.10&f=u
More information about the pld-cvs-commit
mailing list