Plumbing to rename a ref?
- From
- Sergei Organov <osv@javad.com>
- Date
- May 23, 2014, 10:11 UTC
- Message-ID
- <87ha4golck.fsf@osv.gnss.ru>
Hello,
After convertion of a project from CVS to git, I'd like to rename some references in the created git repository (before it's published, so no problems here). Is there a plumbing that would do:
git rename-ref <old_name> <new_name>
for me?
For reference, the (ugly) solution I currrently use is:
# Renamve branches/tags for brevity. # # e.g.: version-3-5-branch -> v3.5-branch #
sed_cmd='sed "s/version-/v/g" | sed "s/\([0-9]\)-\([0-9]\)/\1.\2/g" | sed "s/\([0-9]\)-\([0-9]\)/\1.\2/g"'
if [ -f "packed-refs" ]; then
rm -rf "packed-refs.new"
cat "packed-refs" | eval "$sed_cmd" > "packed-refs.new" && mv "packed-refs.new" "packed-refs"
figit for-each-ref --format="%(refname)" |
while read -r; do
ref="$REPLY"
if [ -f "$ref" ]; then
new_ref=`echo "$ref" | eval "$sed_cmd"`
if [ "$ref" != "$new_ref" ]; then
echo "$ref -> $new_ref"
mv "$ref" "$new_ref"
fi
fi
done-- Sergey.