Created
October 13, 2020 12:28
-
-
Save mspncp/c533cd6c71aa02a8ec42849733b3bd4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -o errexit | |
# This script can be rerun several times. Every time the script is run | |
# it will redo the changes at the current tip of the master branch. | |
# | |
# The first two commits are autogenerated. | |
# | |
# - The first commit renames OPENSSL_CTX -> OSSL_LIB_CTX | |
# - The second commit renames 'library_context' and 'lib_ctx' to 'libctx' | |
# | |
# The other commits are manual fixups. | |
# | |
# The script attempts to rebase the manual fixups automatically on top | |
# of the two autogenerated commits. If the rebase fails, you can try to | |
# resolve the conflicts as for a normal rebase (e.g., using `git mergetool)`, | |
# or you can abort the rebase using `git rebase --abort`, in which case you | |
# end up where the script started. | |
FROM=OPENSSL_CTX | |
TO=OSSL_LIB_CTX | |
from=${FROM,,} | |
to=${TO,,} | |
# The name of the topic branch for pull request #12621; the script expects that this branch exists. | |
# | |
# Actually, the branch name is misleading, but it can't be changed anymore. | |
branch=pr-rename-OPENSSL_CTX-to-OSSL_CONTEXT | |
# the upstream branch: you can set it to master or origin/master, as you prefer | |
upstream=master | |
# remember the last autogenerated commit before the manual fixups | |
fixup_base=$(git log --reverse --oneline --no-decorate ${upstream}..${branch} | grep -v 'fixup!' | tail -1 | cut -d ' ' -f 1) | |
# checkout the upstream branch in detached state (i.e., use HEAD as an unnamed temporary branch) | |
git checkout --detach $upstream | |
# | |
# COMMIT 1: the bulk renaming starts here | |
# | |
# treat util/libcrypto.num and util/other.syms specially, to get the alignment correct | |
git grep -l ${FROM} -- util/ | xargs sed -i -E "s/${FROM}([a-zA-Z0-9_]*) /${TO}\1/g" | |
# rename all the other prefixes, the capital letter and the small letter prefixes separately | |
git grep -il ${FROM} | xargs sed -i "s/${FROM}/${TO}/g;s/${from}/${to}/g" | |
# rename the only file which contains '${FROM}' in its file name | |
git mv doc/man3/${FROM}.pod doc/man3/${TO}.pod | |
# rename the only file which contains '${from}' in its file name | |
git mv doc/internal/man3/${from}_get_data.pod doc/internal/man3/${to}_get_data.pod | |
# commit the changes | |
git commit -a -F - <<EOF | |
Rename ${FROM} prefix to ${TO} | |
Many of the new types introduced by OpenSSL 3.0 have an OSSL_ prefix, | |
e.g., OSSL_CALLBACK, OSSL_PARAM, OSSL_ALGORITHM, OSSL_SERIALIZER. | |
The OPENSSL_CTX type stands out a little by using a different prefix. | |
For consistency reasons, this type is renamed to OSSL_LIB_CTX. | |
EOF | |
# | |
# COMMIT 2: more bulk renaming | |
# | |
FROM=_LIBRARY_CONTEXT | |
TO=_LIBCTX | |
from=${FROM,,} | |
to=${TO,,} | |
git grep -il ${FROM} | xargs sed -i "s/${FROM}/${TO}/g;s/${from}/${to}/g" | |
FROM=ET_LIB_CTX | |
TO=ET_LIBCTX | |
from=${FROM,,} | |
to=${TO,,} | |
git grep -il ${FROM} | xargs sed -i "s/${FROM}/${TO}/g;s/${from}/${to}/g" | |
# commit the changes | |
git commit -a -F - <<EOF | |
Rename some occurrences of 'library_context' and 'lib_ctx' to 'libctx' | |
This change makes the naming more consistent, because three different terms | |
were used for the same thing. (The term libctx was used by far most often.) | |
EOF | |
# | |
# FIXUPS | |
# | |
if [ -n "${fixup_base}" ] ; then | |
echo "Rebasing the fixups" | |
git show -s --oneline --no-decorate ${fixup_base}..${branch} | |
echo "onto the automated commit" | |
git show -s --oneline --no-decorate HEAD | |
# rebase them onto the last automated commit, which is at the detached HEAD | |
git rebase --onto HEAD ${fixup_base} ${branch} | |
fi |
romen
commented
Oct 15, 2020
That was my thought, too. :-) BTW: Didn't you say you can create pull requests? ;-)
That was my thought, too. :-) BTW: Didn't you say you can create pull requests? ;-)
True, check among your forks! 😜
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment