Summary Files Commits Branches @commit @diff @stats
path: root / scripts / archive
blob: ea17aaa06641268cc3d003839b1377cc41e827e2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash

if [ -z "$1" ]
then
	printf 'Repository: '
	read
	set "$REPLY"
fi

set "$(echo -e "a\n$1/\n.\n1s|\.\+/||g\n1s|/\+|/|g\n1p\nQ" | ed -sqr | tail -1)"

if [ ! -d "$1" ]
then
	echo 'Not a directory!'
	exit 1
fi

set "${1%%/objects/*}"
set "${1%%/refs/*}"

__rec_ro() {
	while read -r f
	do
		if [ -n "$f" ]
		then
			chwrite -w "$1/$f"
			if [ -d "$1/$f" ]
			then
				__rec_ro "$1/$f"
			fi
		fi
	done <<FILES
$(ls -A1 "$1")
FILES
}

chwrite -w "$1"
__rec_ro "$1"