@@ 1,11 1,10 @@
#!/bin/sh
. "$(dirname -- "$0")/lib.sh"
-parents=
while getopts p: opt; do
case "$opt" in
p)
- parents="$parents -p $OPTARG"
+ parents="${parents:-} -p $OPTARG"
;;
?)
abort "usage: tm commit [-p <parent>]... [<file>|<directory>]"
@@ 15,9 14,9 @@ done
shift "$((OPTIND - 1))"
-[ -z "$parents" ] && parents="-p HEAD"
+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:-.}"
commit="$(tm commit-tree $parents "$tree")" || abort "failed to commit $tree"
-exec tm update-ref index "$commit"
+exec tm update-ref index "$commit" >/dev/null