summaryrefslogtreecommitdiff
path: root/scripts/hash.rc
blob: 3d7235d7e2d6fa8f15063088e4e15e54e986aed7 (plain)
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
#!/bin/rc

flag e +

repo=$1
out=$2
mode=$3
name=$4
shift 4

fn checkstatus {
	s=$status if(! ~ $s '' '|') exit $s
	status=()
}

hash=`{
	switch($mode) {
	case 120???
		printf %s $1 | git -C $repo hash-object -w --stdin
	case 100???
		git -C $repo hash-object -w --stdin <$1
	}
}
checkstatus

printf '%s %s\t%s\n' $mode $hash $name >$out.tmp
mv $out.tmp $out