blob: 6f6bf740f5126b67118c97c13761aba871c8256f (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
##
# systr_repo_resolve_reference <ref>
#
# Resolve a revision name to a commit ID. The result is printed to
# stdout.
##
function systr_repo_resolve_reference
{
if [ $# -lt 1 ]; then
echo "Fatal: too few args to repo_resolve_reference" >&2
exit 1
fi
ref="$1"
if [[ "$ref" == "BASE" ]]; then
cat .systr/BASE
elif [[ "$ref" == "TRAC" ]]; then
systr_repo_resolve_reference "$TRAC"
elif [[ "$ref" == "NULL" ]]; then
echo "NULL"
else
(
cd "$path"
if [ -f "refs/$ref" ]; then
cat "refs/$ref"
elif [ -f "revs/$ref/.commit.systr" ]; then
echo "$ref"
else
echo "$ref is not a revision" >&2
exit 1
fi
)
fi
}
##
# systrunk log [<commit>=BASE]
#
# View commit history. Generate a dump of all commits reachable
# from the given commit, or BASE if no argument is given.
##
function systr_log
{
if [ $# -lt 1 ]; then
commit="$BASE"
else
commit=$(systr_repo_resolve_reference "$1")
fi
while [[ "$commit" != "NULL" ]]
do
(
cd "$path/revs/$commit/"
read date <.date.systr
read author <.author.systr
read email <.email.systr
printf '%s %s\n' "$commit" "$date"
printf '%s <%s>\n\n' "$author" "$email"
cat .mesg.systr
echo ""
echo ""
)
read commit <"$path/revs/$commit/.commit.systr"
done
}
##
# systrunk init <name>
#
# Initialize a repository called "<name>.systr" in the current
# directory.
##
function systr_init
{
if [ $# -lt 1 ]; then
echo "Fatal: too few args to init" >&2
exit 1
fi
name="$1"
mkdir "$name.systr"
cd "$name.systr"
mkdir refs revs
echo "NULL" >refs/HEAD
}
|