blob: 4ec51bb85b734f2bad064ca6a3a89855ff9b3df8 (
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/bin/dash
# Test if we have a valid repo before doing anything.
if ! [ -d ".tigger/" ]; then
printf "tigger-add: error: tigger repository directory .tigger not found\n"
exit 1
fi
# Get current branch, then current commit (default 0).
branch=$(cat .tigger/branch.tig)
mkdir --parents ".tigger/$branch/"
# Grabs the latest commit
commit=$(find .tigger/"$branch"/ -maxdepth 1 -type d | grep -o -E "[\/][^\/]*$" | tr -d "/" | sort -n -r | head -n 1)
if [ "$commit" = "" ]; then
commit="0"
mkdir --parents ".tigger/$branch/$commit/"
fi
staged_dir=".tigger/$branch/$commit/staged/"
mkdir --parents "$staged_dir"
for filename in "$@"; do
if ! [ -f "$filename" ]; then
# If it doesn't exist in the dir, but does exist in staged, delete staged.
if [ -f .tigger/"$branch"/"$commit"/staged/"$filename" ]; then
rm --force .tigger/"$branch"/"$commit"/staged/"$filename"
continue
fi
printf "tigger-add: error: can not open '%s'\n" "$filename"
exit 1
fi
cp "$filename" "$staged_dir"
done
exit 0
|