Created
August 3, 2018 20:24
-
-
Save baileyparker/ee49d526ed80c77bf5b1e55256ead049 to your computer and use it in GitHub Desktop.
Script that removes slashes from bup backup names
This file contains hidden or 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 -e | |
if [ "$#" -eq "1" ]; then | |
git_dir="$1" | |
else | |
if [ "$#" -eq "0" ]; then | |
git_dir="~/.bup" | |
else | |
echo "usage: $0 [bup-dir]" 1>&2 | |
exit 1 | |
fi | |
fi | |
git='git --git-dir='"$git_dir" | |
for branch in $($git for-each-ref --format='%(refname)' refs/heads); do | |
branch_name=${branch#refs/heads/} | |
if [[ $branch_name =~ / ]]; then | |
fixed_branch_name=${branch_name//\//-} | |
$git branch "$fixed_branch_name" "$branch_name" > /dev/null | |
$git branch -D "$branch_name" > /dev/null | |
echo "renamed $branch_name to $fixed_branch_name" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment