#!/bin/bash #$1 : URL to download .git from (http://target.com/.git/) #$2 : Folder where the .git-directory will be created function init_header() { cat < /dev/null); then #Delete invalid file cd "$cwd" rm "$target" return fi #Parse output of git cat-file -p $hash. Use strings for blobs if [[ "$type" != "blob" ]]; then hashes+=($(git cat-file -p "$hash" | grep -oE "([a-f0-9]{40})")) else hashes+=($(git cat-file -p "$hash" | strings -a | grep -oE "([a-f0-9]{40})")) fi cd "$cwd" fi #Parse file for other objects hashes+=($(cat "$target" | strings -a | grep -oE "([a-f0-9]{40})")) for hash in ${hashes[*]} do QUEUE+=("objects/${hash:0:2}/${hash:2}") done #Parse file for packs packs+=($(cat "$target" | strings -a | grep -oE "(pack\-[a-f0-9]{40})")) for pack in ${packs[*]} do QUEUE+=("objects/pack/$pack.pack") QUEUE+=("objects/pack/$pack.idx") done } start_download