Files
boost-tasks/doc-build/git-export
2015-06-03 23:20:19 +01:00

43 lines
933 B
Bash
Executable File

#!/bin/bash -e
set -e
set -u
cd $(dirname $0)
root=$(pwd)
. $root/settings.sh
git_export()
{
git_dir=$1
ref=$2
destination=$3
echo "Exporting ${ref} from ${git_dir}"
mkdir -p $destination
git --git-dir=${git_dir} archive ${ref} | tar -x -C ${destination}
git config -f $destination/.gitmodules -l |
sed -n 's/submodule\.\([^.]*\)\.path=\(.*\)/\1 \2/p' |
while read line
do
set $line
name=$1
path=$2
hash=$(git --git-dir=$git_dir \
ls-tree $ref $path |
cut -f 1 | cut -d ' ' -f 3)
repo=$(git config -f $destination/.gitmodules submodule.$name.url)
#TODO: Check that repo is a relative path...
echo "Export ${name}"
git --git-dir=${git_dir}/${repo} archive ${hash} |
tar -x -C ${destination}/${path}
done
}
git_export $*