~ecs/tm

ref: 0022137d89f12741ac3e6cf4173aa876cda5a726 tm/tm-next -rwxr-xr-x 456 bytes
0022137dEmber Sawady Fix shellcheck warnings 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/sh

# shellcheck source=./lib.sh
. "$(dirname -- "$0")/lib.sh"
[ $# -gt 1 ] && abort "usage: tm next [<ref>]"
new="$(tm resolve-ref "${1:-index}")" || exit 1
for ref in "$TM_DIR/refs/"*; do
	[ "z$ref" = "zHEAD" ] && continue
	# XXX: is this the right thing to do?
	[ "z$ref" = "zindex" ] && continue
	resolved="$(tm resolve-ref "$ref")" || exit 1
	[ "z$new" = "z$resolved" ] && tm update-ref "$ref" "${1:-index}"
done
exec tm update-ref HEAD "$new"