~ecs/tm

ref: 95cb618f450695312ff6849e7c6e86709e985ae9 tm/tm-resolve-ref -rwxr-xr-x 404 bytes
95cb618fEmber Sawady init: use commit instead of commit-tree 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh -eu

. "$(dirname -- "$0")/lib.sh"
if [ $# -ne 1 ]; then
	abort "usage: tm resolve-ref <ref>"
fi

# TODO: ref~X, ref^X
if [ -f "$TM_DIR/refs/$1" ]; then
	tm resolve-ref "$(cat "$TM_DIR/refs/$1")"
elif [ "$(echo "$TM_DIR/objects/$1"* | awk '{print NF}')" -eq 1 ] \
		&& [ -f "$TM_DIR/objects/$1"* ]; then
	printf "%s\n" "$(basename "$TM_DIR/objects/$1"*)"
else
	abort "error: invalid ref $1"
fi