diff options
-rwxr-xr-x | scripts/mageia-reset-and-import.sh | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh index d2d8d9d..b7badc1 100755 --- a/scripts/mageia-reset-and-import.sh +++ b/scripts/mageia-reset-and-import.sh @@ -332,40 +332,40 @@ git branch -D origin/master 2>/dev/null declare -A tagmap tags=$(git for-each-ref --format='%(refname)' refs/heads/tags | cut -d / -f 4) for tag in $tags; do - ref="refs/heads/tags/$tag" - refsha1=$(git rev-parse "$ref") - reftreesha1=$(git rev-parse "$ref":) - - # Find the oldest ancestor for which the tree is the same - parentref="$ref" - while [ $(git rev-parse --quiet --verify "$parentref"^:) = "$reftreesha1" ]; do - parentref="$parentref"^ - done - parent=$(git rev-parse "$parentref") - - # If this ancestor is in master then we can just tag it - # otherwise the tag has diverged from master and it's actually more like a - # branch than a tag - merge=$(git merge-base master $parent) - if [ "$merge" = "$parent" ]; then - targetref=$parent - else - targetref=$refsha1 - fi + ref="refs/heads/tags/$tag" + refsha1=$(git rev-parse "$ref") + reftreesha1=$(git rev-parse "$ref":) + + # Find the oldest ancestor for which the tree is the same + parentref="$ref" + while [ $(git rev-parse --quiet --verify "$parentref"^:) = "$reftreesha1" ]; do + parentref="$parentref"^ + done + parent=$(git rev-parse "$parentref") + + # If this ancestor is in master then we can just tag it + # otherwise the tag has diverged from master and it's actually more like a + # branch than a tag + merge=$(git merge-base master $parent) + if [ "$merge" = "$parent" ]; then + targetref=$parent + else + targetref=$refsha1 + fi - tagmap[$refsha1]=$tag + tagmap[$refsha1]=$tag - # create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag - git show -s --pretty='format:%s%n%n%b' "$ref" | \ - env GIT_COMMITTER_NAME="$(git show -s --pretty='format:%an' "$ref")" \ - GIT_COMMITTER_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \ - GIT_COMMITTER_DATE="$(git show -s --pretty='format:%ad' "$ref")" \ - GIT_AUTHOR_NAME="$(git show -s --pretty='format:%an' "$ref")" \ - GIT_AUTHOR_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \ - GIT_AUTHOR_DATE="$(git show -s --pretty='format:%ad' "$ref")" \ - git tag -a -F - "$tag" "$targetref" + # create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag + git show -s --pretty='format:%s%n%n%b' "$ref" | \ + env GIT_COMMITTER_NAME="$(git show -s --pretty='format:%an' "$ref")" \ + GIT_COMMITTER_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \ + GIT_COMMITTER_DATE="$(git show -s --pretty='format:%ad' "$ref")" \ + GIT_AUTHOR_NAME="$(git show -s --pretty='format:%an' "$ref")" \ + GIT_AUTHOR_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \ + GIT_AUTHOR_DATE="$(git show -s --pretty='format:%ad' "$ref")" \ + git tag -a -F - "$tag" "$targetref" - git update-ref -d "$ref" + git update-ref -d "$ref" done git gc --aggressive |