~ecs/tm

ref: 0022137d89f12741ac3e6cf4173aa876cda5a726 tm/tm-commit -rwxr-xr-x 705 bytes
0022137dEmber Sawady Fix shellcheck warnings 2 years ago
                                                                                
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
#!/bin/sh

# shellcheck source=./lib.sh
. "$(dirname -- "$0")/lib.sh"
while getopts p: opt; do
	case "$opt" in
	p)
		parents="${parents:-} -p $OPTARG"
		;;
	?)
		abort "usage: tm commit [-p <parent>]... [<file>|<directory>]"
		;;
	esac
done

shift "$((OPTIND - 1))"

tm resolve-ref HEAD >/dev/null 2>/dev/null && : "${parents=-p HEAD}"

[ $# -gt 1 ] && abort "usage: tm commit [-p <parent>]... [<file>|<directory>]"
tree="$(tm insert "${1:-.}")" || abort "failed to insert ${1:-.}"
set -f
# This \o/ is \o/ really \o/ really \o/ dumb
# shellcheck disable=SC2086
set -- $parents
set +f
commit="$(tm commit-tree "$@" "$tree")" || abort "failed to commit $tree"
exec tm update-ref index "$commit" >/dev/null