Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/bin/clean-git
diff options
context:
space:
mode:
Diffstat (limited to 'bin/clean-git')
-rwxr-xr-xbin/clean-git29
1 files changed, 25 insertions, 4 deletions
diff --git a/bin/clean-git b/bin/clean-git
index d8f5166..0b892a2 100755
--- a/bin/clean-git
+++ b/bin/clean-git
@@ -9,9 +9,30 @@
for repo in ${repo_names}; do
eval 'repo_path="${repo_paths__'"${repo}"'}"'
- printf 'cleaning %s (%s) ...\n' \
- "${repo}" \
- "${repo_path}"
- ionice -n 7 git -C "${repo_path}" gc
+ while [ "${repo_path}" != "${repo_path%/}" ]; do
+ repo_path="${repo_path%/}"
+ done
+ remote=$(
+ git -C "${repo_path}" remote -v \
+ | awk '{print $2}' \
+ | sort -u
+ )
+ if printf '%s\n' "${remote}" \
+ | wc -l \
+ | grep -xqF 1 ; then
+ printf 'recloning %s (%s) ...\n' \
+ "${repo}" \
+ "${repo_path}"
+ git clone --bare "${repo_path}" "${repo_path}.new"
+ git -C "${repo_path}.new" remote set-url origin "${remote}"
+ mv "${repo_path}" "${repo_path}.old"
+ mv "${repo_path}.new" "${repo_path}"
+ rm -rf --one-file-system "${repo_path}.old"
+ else
+ printf 'cleaning %s (%s) ...\n' \
+ "${repo}" \
+ "${repo_path}"
+ ionice -n 7 git -C "${repo_path}" gc
+ fi
printf '... done\n'
done