-
Notifications
You must be signed in to change notification settings - Fork 0
/
legit-show
43 lines (36 loc) · 880 Bytes
/
legit-show
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
39
40
41
42
43
#!/bin/dash
export PATH=$PATH:.
details=$1
# split up
i=$(echo "$details" | cut -d':' -f1)
file=$(echo "$details" | cut -d':' -f2)
if [ "$i" = '' ]
then
# file not found in index
if [ ! -f ".legit/index/$file" ]
then
echo "legit-show: error: '$file' not found in index"
exit
fi
else
# commit directory not found
if [ ! -d ".legit/commit.$i" ]
then
echo "legit-show: error: unknown commit '$i'"
exit
fi
# file not found in commit directory
if [ ! -f ".legit/commit.$i/$file" -a ! -f ".legit/commit.$i/$file." ]
then
echo "legit-show: error: '$file' not found in commit $i"
exit
fi
fi
if [ "$i" = '' ]
then
# print contents of file in index since commit num not provided
cat .legit/index/$file
else
# print .legit/commit.i/file
cat .legit/commit.$i/$file
fi