Debian Codegraph @

tools/convert-git-annex-layout

raw
1 #!/bin/bash
2
3 set -eu
4
5 to="$1"
6
7 echo "Initial fsck:"
8 git annex fsck --fast 2>&1 | python -m tqdm --null
9 echo "Going through objects: "
10 for f in .git/annex/objects/*/*/*; do
11 key=$(basename $f)
12 keydir=$(dirname $f)
13 newhashdir=$(git annex examinekey --format="\${$to}" "$key")
14 targetdir=".git/annex/objects/$newhashdir"
15 test -n "$newhashdir"
16 if [ "$keydir" = "${targetdir%/}" ]; then
17 continue
18 fi
19 echo " $f -> $newhashdir"
20 # This was a wrong assumption - there could be multiple
21 # keys in the same directory so we might have it already.
22 # But I still feel we might need some test here
23 #if test -e "$targetdir"; then
24 # echo "$targetdir already exists"
25 # exit 1
26 #fi
27 mkdir -p "$(dirname $targetdir)"
28 mv "$keydir" "${targetdir%/}"
29 done
30 echo "Final fsck:"
31 git annex fsck --fast 2>&1 | python -m tqdm --null