Skip to content

Instantly share code, notes, and snippets.

@yarikoptic
Created January 9, 2015 05:03
Show Gist options
  • Save yarikoptic/a9278987227a04ce651f to your computer and use it in GitHub Desktop.
Save yarikoptic/a9278987227a04ce651f to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eu
cd $1
# First we will deal with .git/annex/objects
for d in .git/annex/objects/??/??/*; do
[ -d $d ] || continue
chmod +w $d $d/..
# although it must be the same name, let's be uber careful
mv $d ${d}_
mv ${d}_/* ${d}_/..
rmdir ${d}_
echo -n ,
done
# now remap all the symlinks
find -type l \
| while read f; do
l=$(readlink "$f")
rm $f; ln -s ${l%/*} $f
# check if link is not broken
[ -e $f ] || { echo BROKEN; exit 999; }
echo -n .
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment