Skip to content

Instantly share code, notes, and snippets.

@baileyparker
Created August 3, 2018 20:24
Show Gist options
  • Save baileyparker/ee49d526ed80c77bf5b1e55256ead049 to your computer and use it in GitHub Desktop.
Save baileyparker/ee49d526ed80c77bf5b1e55256ead049 to your computer and use it in GitHub Desktop.
Script that removes slashes from bup backup names
#!/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