Skip to content

Commit

Permalink
[tools] Fix git-vault-export to read symbolic link names with spaces.…
Browse files Browse the repository at this point in the history
… Fixes JB#35155

If a file name in the backup has a space, the link is currently
expanded without quotation marks, causing the readlink operation to
fail, thus causing the file to be added to the backup as a symbolic
link rather than a hard link, and thus the file is not actually
added to the backup.
  • Loading branch information
Bea Lam committed Aug 23, 2016
1 parent 08459f9 commit 7ab0630
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/git-vault-export
Expand Up @@ -36,15 +36,15 @@ GIT_DIR=$(pwd)

find $DST -type l | grep '/blobs/' | while read -r LINK
do
NAME=$(readlink $LINK)
NAME=$(readlink "$LINK")
# match minimal relative blob ref (path inside the tree is unit/blobs/link)
if [[ $NAME =~ \.\./\.\./\.git/blobs/ ]]; then
FNAME=$(basename $NAME)
DNAME="$GIT_DIR/.git/blobs/$(basename $(dirname $NAME))"
[ -d $DNAME ] || error "There is no blob dir $DNAME for $LINK"
FNAME="$DNAME/$FNAME"
[ -f $FNAME ] || error "There is no blob file $FNAME for $LINK"
unlink $LINK || error "Can't unlink $LINK"
cp $FNAME $LINK || error "Can't copy $FNAME to $LINK"
unlink "$LINK" || error "Can't unlink $LINK"
cp $FNAME "$LINK" || error "Can't copy $FNAME to $LINK"
fi
done

0 comments on commit 7ab0630

Please sign in to comment.