contrib: Clean up outdated parts of gcc-git-customization.sh

It's very unlikely that anybody is still using the old remotes/$user Git
repo setup and still needs this script to be able to migrate it to the
remotes/users/$user structure. Simplify the script by removing those
parts.

This fixes an error that gets displayed in some circumstances:
fatal: no such section: remote.me

contrib/ChangeLog:

	* gcc-git-customization.sh: Delete outdated commands for
	migrating from very old git setups.
This commit is contained in:
Jonathan Wakely 2025-03-06 20:28:07 +00:00 committed by Jonathan Wakely
parent 81582ca6cb
commit 34bc3118d9
No known key found for this signature in database

View file

@ -156,45 +156,7 @@ if [ "x$dohook" = xyes ]; then
fi
fi
# Scan the existing settings to see if there are any we need to rewrite.
vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed 's:.*refs/vendors/\([^/][^/]*\)/.*:\1:' | sort | uniq)
url=$(git config --get "remote.${upstream}.url")
pushurl=$(git config --get "remote.${upstream}.pushurl")
for v in $vendors
do
echo "Migrating vendor \"$v\" to new remote \"vendors/$v\""
git config --unset-all "remote.${upstream}.fetch" "refs/vendors/$v/"
git config --unset-all "remote.${upstream}.push" "refs/vendors/$v/"
git config "remote.vendors/${v}.url" "${url}"
if [ "x$pushurl" != "x" ]
then
git config "remote.vendors/${v}.pushurl" "${pushurl}"
fi
git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/heads/*:refs/remotes/vendors/${v}/*"
git config --add "remote.vendors/${v}.fetch" "+refs/vendors/$v/tags/*:refs/tags/vendors/${v}/*"
done
# Convert the remote 'pfx' to users/pfx to avoid problems with ambiguous refs
# on user branches
old_remote=$(git config --get "remote.${old_pfx}.url")
if [ -n "${old_remote}" ]
then
echo "Migrating remote \"${old_pfx}\" to new remote \"users/${new_pfx}\""
# Create a dummy fetch rule that will cause the subsequent prune to remove the old remote refs.
git config --replace-all "remote.${old_pfx}.fetch" "+refs/empty/*:refs/remotes/${old_pfx}/*"
# Remove any remotes
git remote prune ${old_pfx}
git config --remove-section "remote.${old_pfx}"
for br in $(git branch --list "${old_pfx}/*")
do
old_remote=$(git config --get "branch.${br}.remote")
if [ "${old_remote}" = "${old_pfx}" ]
then
git config "branch.${br}.remote" "users/${new_pfx}"
fi
done
fi
echo "Setting up tracking for personal namespace $remote_id in remotes/users/${new_pfx}"
git config "remote.users/${new_pfx}.url" "${url}"
if [ "x$pushurl" != "x" ]
@ -205,12 +167,4 @@ git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_i
git config --replace-all "remote.users/${new_pfx}.fetch" "+refs/users/${remote_id}/tags/*:refs/tags/users/${new_pfx}/*" "refs/users/${remote_id}/tags/"
git config --replace-all "remote.users/${new_pfx}.push" "refs/heads/${new_pfx}/*:refs/users/${remote_id}/heads/*" "refs/users/${remote_id}"
if [ "$old_pfx" != "$new_pfx" -a "$old_pfx" != "${upstream}" ]
then
git config --remove-section "remote.${old_pfx}"
fi
git config --unset-all "remote.${upstream}.fetch" "refs/users/${remote_id}/"
git config --unset-all "remote.${upstream}.push" "refs/users/${remote_id}/"
git fetch "users/${new_pfx}"