Luckily I only had a chance to mess this up in one fork.
And I don't need to actually make any changes because my definitions are order-independent.
O5GJ6PNNBYHH4X3DU4XOB7IDJ4QEW5KXFETIDUJESBUKJYXBSYYAC
7KX3WBFEXMIHNKWNF4NUOBW5HO3PEL3ZEFFMTAXFOQG6V7BYXZ3AC
R5QXEHUIZLELJGGCZAE7ATNS3CLRJ7JFRENMGH4XXH24C5WABZDQC
7TQAF4BYIK75EEYCCK7VEUSZHNCWMWIA3HZGQKIILYESUZ5ZZRVQC
MAUOADNV62ZEWXWUTNJPVNWE6IFEDN23F6S5YVWW743EQJQ6NNVAC
Y6O2RFHV5UGHFS3ZZEH5HPKN5I7SV74GEV47MTI4WGJPAINJMBZAC
4IGCV3VLATQW2E2XDVBJ4BZWBMVZ2PNQI2EJFRZSVF4RMAT5TBYQC
AKQBXWCVTZ5LEG76QW54B7MHXYFA7GD2Y2GSEN7RUXO5CHMYCZKAC
K6ZDYZKXSLTLCCHWYK6K6WOCNXBZOXEDKDVNNJVCZUFOLLSUO5UAC
QJAYOFWY7V4BWVLJMEDCCBC2HX4BDAZI6PQVLWCLYRHWGMOBFTVAC
PPVABNGQTQMPYILHDNSNXBI5IOCBSIYO45NIHUR4LYPABQZE6PAQC
JIBCE66ZTWM5WEHEHNKKTRWBJQSQWBDDWPMOJIJR5Q676OSHYCNAC
BF7TW3EKRIDYC6J2Q2J4YOBAVQF55Y3H6KGZIHNXMH4N72MR6GXQC
TBPJ5WSRM5IKQH7FTAVYTWWUBWW7G2CLT5M6FN7CMPLD6Y77YIWQC
6FM47PAEXXD74ABGEP7AJT7PA3U3SERUAEE6PHJJMBXLKPHLKJSQC
ZQMQVMFWZIGWBRCB455IKHPTAOUYPLYCSC44NBPPET557RGVRX3AC
FBDRJ53NJ5BWDQGU2GWZ6NEYHKCCRD7RODMIG7QQZBRFUB4HR7OAC
FAZW23IDQ6JTXYSJXB5XEALXTWXSDRTDDBBIOWIOKPQ2R3S3WUMQC
PHJEOJAWCHNI4CGTSAJQTWM3UFP6N6J3ZF2TRSSIR4S42OF2PZUQC
X7HYGAL2QVKG7M5EMZ2VSH37UYWGE3EPUXYQBJOVL6IGJFZ2I5AAC
4WW67KAXORLJFOJVWV3CP4VNHTEIJY5WQMSDMXMFKRWSI5EEHTRAC
KV64IWA3DKR4FL6E4BIG5SFCRQJ3DZFEJOUELCD5TC7DDVJQ6SWAC
4TL2FLYP36JS4K6QBXZBCFCTIBMIT7OAF7KMAAFGPAF5OWSP4QFAC
Q2C4QGRCXKMCWMEQJT2OJMC5A3OIYKWPQBU4U3QWICEJHFXO6LPQC
VHT5NALKBXY6CZ2AJPLIJ33OSP5X2TF6GTDMIYXVKNIXPZXPAMAAC
#!/bin/bash
# Based on https://github.com/akkartik/mu1/blob/master/relayout
set -e
if [[ $# -eq 0 && `git diff HEAD |wc -l` -gt 0 ]]
then
echo "Uncommitted changes"
exit
fi
# Phase 1
#? index=0
#? ls [0-9]* |sort -n |
#? while read file
#? do
#? while [[ $file != `printf "%04d" $index`* ]]
#? do
#? echo
#? index=$(($index+1))
#? done
#? echo $file |sed 's/^....-//'
#? index=$(($index+1))
#? done > .layout
root() {
echo $1 |sed 's/^[0-9]*-//'
}
# Phase 2
index=0
cat $1 |
while read file
do
echo $index $file
if [ ! -z $file ]
then
file=$(ls |grep ".-$file\$")
newfile=$(printf "%04d-%s" $index `root $file`)
echo "=> $newfile"
if [[ $newfile != $file ]]
then
echo git mv $file $newfile
git mv $file $newfile
fi
fi
index=$(($index+1))
done